From 2719c825c6b82813a42f7a3f106156ac4ccefcb0 Mon Sep 17 00:00:00 2001 From: Ivan Folgueira Bande Date: Sun, 28 Jul 2024 17:15:22 +0200 Subject: [PATCH] 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. --- libp2p/utility.nim | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/libp2p/utility.nim b/libp2p/utility.nim index 542eff026..9b115822f 100644 --- a/libp2p/utility.nim +++ b/libp2p/utility.nim @@ -10,8 +10,9 @@ {.push raises: [].} import std/[sets, options, macros] -import stew/[byteutils, results] +import stew/byteutils +import results export results template public*() {.pragma.} @@ -124,13 +125,6 @@ macro withValue*[T](self: Opt[T] | Option[T], value, body, elseStmt: untyped): u else: `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] = let temp = (self) if temp.isOk: