From 5a273e40705fde8a36c984353680ee9b8b988094 Mon Sep 17 00:00:00 2001 From: Pi Delport Date: Thu, 17 Jun 2021 10:25:39 +0200 Subject: [PATCH] feat(rtc_types::ecall_result): add EcallResult::map method --- rtc_types/src/ecall_result.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/rtc_types/src/ecall_result.rs b/rtc_types/src/ecall_result.rs index 5e2f0eca..ece1f397 100644 --- a/rtc_types/src/ecall_result.rs +++ b/rtc_types/src/ecall_result.rs @@ -8,6 +8,17 @@ pub enum EcallResult { Err(E), } +impl EcallResult { + /// See [`Result::map`] + pub fn map U>(self, op: F) -> EcallResult { + use EcallResult::{Err, Ok}; + match self { + Ok(t) => Ok(op(t)), + Err(e) => Err(e), + } + } +} + impl EcallResult where E: 'static + std::error::Error + Display,