Overload toOption for Result

Necessary for the `=?` operator to work.
This commit is contained in:
Nickolay Bukreyev 2023-11-14 14:41:10 +07:00 committed by markspanbroek
parent cdf639c4ea
commit 0f095d6b7c

View File

@ -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.