Skip to content
This repository has been archived by the owner on May 9, 2022. It is now read-only.

Commit

Permalink
feat(rtc_types::ecall_result): add EcallResult::map method
Browse files Browse the repository at this point in the history
  • Loading branch information
PiDelport committed Jun 17, 2021
1 parent 26318d0 commit 5a273e4
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions rtc_types/src/ecall_result.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,17 @@ pub enum EcallResult<T, E> {
Err(E),
}

impl<T, E> EcallResult<T, E> {
/// See [`Result::map`]
pub fn map<U, F: FnOnce(T) -> U>(self, op: F) -> EcallResult<U, E> {
use EcallResult::{Err, Ok};
match self {
Ok(t) => Ok(op(t)),
Err(e) => Err(e),
}
}
}

impl<T, E> EcallResult<T, E>
where
E: 'static + std::error::Error + Display,
Expand Down

0 comments on commit 5a273e4

Please sign in to comment.