From 0f095d6b7c72b695305922f8f3ef601550527f4b Mon Sep 17 00:00:00 2001 From: Nickolay Bukreyev Date: Tue, 14 Nov 2023 14:41:10 +0700 Subject: [PATCH] Overload `toOption` for `Result` Necessary for the `=?` operator to work. --- questionable/results.nim | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/questionable/results.nim b/questionable/results.nim index 5d61945..396f618 100644 --- a/questionable/results.nim +++ b/questionable/results.nim @@ -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.