From 911f4ad81e389dea68be7d1d5819039e7c2a4921 Mon Sep 17 00:00:00 2001 From: Savanni D'Gerinel Date: Wed, 11 Oct 2023 17:36:12 -0400 Subject: [PATCH] Add conversions between Sled results and Flow results --- result-extended/src/lib.rs | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/result-extended/src/lib.rs b/result-extended/src/lib.rs index b56be5f..e4b0bdd 100644 --- a/result-extended/src/lib.rs +++ b/result-extended/src/lib.rs @@ -141,6 +141,30 @@ where } } +impl From, FE>> + for Result +{ + fn from(res: std::result::Result, FE>) -> Self { + match res { + Ok(Ok(v)) => ok(v), + Ok(Err(e)) => error(e), + Err(e) => fatal(e), + } + } +} + +impl From> + for std::result::Result, FE> +{ + fn from(res: Result) -> std::result::Result, FE> { + match res { + Result::Ok(v) => Ok(Ok(v)), + Result::Err(e) => Ok(Err(e)), + Result::Fatal(e) => Err(e), + } + } +} + /// Convenience function to create an ok value. pub fn ok(val: A) -> Result { Result::Ok(val)