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

Commit

Permalink
Merge pull request #101 from registreerocks/feat-EcallResult-map
Browse files Browse the repository at this point in the history
feat(rtc_types::ecall_result): add EcallResult::map method
  • Loading branch information
PiDelport authored Jun 17, 2021
2 parents 26318d0 + 5a273e4 commit b2f083b
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 b2f083b

Please sign in to comment.