MCPcopy
hub / github.com/samber/mo / ExampleResult_Map_ok

Function ExampleResult_Map_ok

result_example_test.go:279–289  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

277}
278
279func ExampleResult_Map_ok() {
280 ok := Ok(42)
281 result := ok.Map(
282 func(i int) (int, error) {
283 return i * 2, nil
284 },
285 )
286
287 fmt.Println(result.IsError(), result.OrEmpty(), result.Error())
288 // Output: false 84 <nil>
289}
290
291func ExampleResult_Map_err() {
292 ko := Err[int](err)

Callers

nothing calls this directly

Calls 5

OkFunction · 0.85
IsErrorMethod · 0.80
ErrorMethod · 0.80
MapMethod · 0.65
OrEmptyMethod · 0.45

Tested by

no test coverage detected