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

Commit b2f083b

Browse files
authored
Merge pull request #101 from registreerocks/feat-EcallResult-map
feat(rtc_types::ecall_result): add EcallResult::map method
2 parents 26318d0 + 5a273e4 commit b2f083b

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

rtc_types/src/ecall_result.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,17 @@ pub enum EcallResult<T, E> {
88
Err(E),
99
}
1010

11+
impl<T, E> EcallResult<T, E> {
12+
/// See [`Result::map`]
13+
pub fn map<U, F: FnOnce(T) -> U>(self, op: F) -> EcallResult<U, E> {
14+
use EcallResult::{Err, Ok};
15+
match self {
16+
Ok(t) => Ok(op(t)),
17+
Err(e) => Err(e),
18+
}
19+
}
20+
}
21+
1122
impl<T, E> EcallResult<T, E>
1223
where
1324
E: 'static + std::error::Error + Display,

0 commit comments

Comments
 (0)