mirror of
https://github.com/status-im/nim-libp2p.git
synced 2025-02-12 21:07:40 +00:00
add withvalue for result
This commit is contained in:
parent
63b6390d1a
commit
d7c0486968
@ -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:
|
||||
|
Loading…
x
Reference in New Issue
Block a user