resultutils to make Result handling easier.
inspired by optionsutils.
import results, resultsutils
func greet(name: string): Result[string, string] =
if name.len > 0:
return ok("hi, " & name)
return err("No name? 😐")
let hiNim: string = match greet "Nim":
Ok(greet):
greet
Err(_):
"Oh no! something went wrong 😨"
assert hiNim == "hi, Nim"
more code examples can be found here
nimble install resultsutils
or add a dependency to your .nimble file:
requires "resultsutils"