mirror of
https://github.com/logos-storage/questionable.git
synced 2026-01-02 13:53:11 +00:00
Overload toOption for Result
Necessary for the `=?` operator to work.
This commit is contained in:
parent
cdf639c4ea
commit
0f095d6b7c
@ -116,6 +116,11 @@ proc option*[T,E](value: Result[T,E]): ?T =
|
||||
else:
|
||||
T.none
|
||||
|
||||
template toOption*[T, E](value: Result[T, E]): ?T =
|
||||
## Converts a Result into an Option.
|
||||
|
||||
value.option
|
||||
|
||||
proc errorOption*[T, E](value: Result[T, E]): ?E =
|
||||
## Returns an Option that contains the error from the Result, if it has one.
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user