add withvalue for result

This commit is contained in:
Diego 2024-05-15 16:14:37 +02:00
parent 63b6390d1a
commit d7c0486968
No known key found for this signature in database
GPG Key ID: C9DAC9BF68D1F806
1 changed files with 3 additions and 0 deletions

View File

@ -112,6 +112,9 @@ template withValue*[T](self: Opt[T] | Option[T], value, body: untyped): untyped
let value {.inject.} = temp.get()
body
template withValue*[T, E](self: Result[T, E], value, body: untyped): untyped =
self.toOpt().withValue(value, body)
macro withValue*[T](self: Opt[T] | Option[T], value, body, elseStmt: untyped): untyped =
let elseBody = elseStmt[0]
quote do: