mirror of
https://github.com/logos-storage/questionable.git
synced 2026-01-05 07:13:09 +00:00
Calling success without arguments returns ?!void result
This commit is contained in:
parent
a66e42d058
commit
144c70580a
@ -15,6 +15,9 @@ template `?!`*(T: typed): type Result[T, ref CatchableError] =
|
||||
proc success*[T](value: T): ?!T =
|
||||
ok(?!T, value)
|
||||
|
||||
proc success*: ?!void =
|
||||
ok(?!void)
|
||||
|
||||
proc failure*(T: type, error: ref CatchableError): ?!T =
|
||||
err(?!T, error)
|
||||
|
||||
|
||||
@ -112,6 +112,9 @@ suite "result":
|
||||
check parseInt("42").catch == 42.success
|
||||
check parseInt("foo").catch.error of ValueError
|
||||
|
||||
test "success can be called without argument":
|
||||
check (success() is ?!void)
|
||||
|
||||
test "failure can be called with string argument":
|
||||
let value = int.failure("some failure")
|
||||
check value.error of ResultFailure
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user