diff --git a/src/vm.rs b/src/vm.rs index 47219c8f..069347a5 100644 --- a/src/vm.rs +++ b/src/vm.rs @@ -79,6 +79,22 @@ impl StableResult { } } + /// Maps ok values, leaving error values untouched + pub fn map U>(self, op: O) -> StableResult { + match self { + Self::Ok(value) => StableResult::::Ok(op(value)), + Self::Err(error) => StableResult::::Err(error), + } + } + + /// Maps error values, leaving ok values untouched + pub fn map_err F>(self, op: O) -> StableResult { + match self { + Self::Ok(value) => StableResult::::Ok(value), + Self::Err(error) => StableResult::::Err(op(error)), + } + } + #[cfg_attr( any( not(feature = "jit"),