mirror of
https://github.com/status-im/nim-libp2p.git
synced 2025-02-01 15:47:04 +00:00
remove valueOr template from utility-nim
This template is already defined in https://github.com/arnetheduck/nim-results, which is the one that we are using in nwaku. Therefore, with that commit we are willing to prevent conflicts between the two 'valueOr' implementations.
This commit is contained in:
parent
f8d4da6421
commit
2719c825c6
@ -10,8 +10,9 @@
|
|||||||
{.push raises: [].}
|
{.push raises: [].}
|
||||||
|
|
||||||
import std/[sets, options, macros]
|
import std/[sets, options, macros]
|
||||||
import stew/[byteutils, results]
|
import stew/byteutils
|
||||||
|
|
||||||
|
import results
|
||||||
export results
|
export results
|
||||||
|
|
||||||
template public*() {.pragma.}
|
template public*() {.pragma.}
|
||||||
@ -124,13 +125,6 @@ macro withValue*[T](self: Opt[T] | Option[T], value, body, elseStmt: untyped): u
|
|||||||
else:
|
else:
|
||||||
`elseBody`
|
`elseBody`
|
||||||
|
|
||||||
template valueOr*[T](self: Option[T], body: untyped): untyped =
|
|
||||||
let temp = (self)
|
|
||||||
if temp.isSome:
|
|
||||||
temp.get()
|
|
||||||
else:
|
|
||||||
body
|
|
||||||
|
|
||||||
template toOpt*[T, E](self: Result[T, E]): Opt[T] =
|
template toOpt*[T, E](self: Result[T, E]): Opt[T] =
|
||||||
let temp = (self)
|
let temp = (self)
|
||||||
if temp.isOk:
|
if temp.isOk:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user