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

Function ExampleResult_Map_err

result_example_test.go:291–301  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

289}
290
291func ExampleResult_Map_err() {
292 ko := Err[int](err)
293 result := ko.Map(
294 func(i int) (int, error) {
295 return i * 2, nil
296 },
297 )
298
299 fmt.Println(result.IsError(), result.OrEmpty(), result.Error())
300 // Output: true 0 error
301}
302
303func ExampleResult_MapValue_ok() {
304 ok := Ok("hello")

Callers

nothing calls this directly

Calls 4

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

Tested by

no test coverage detected