result_ext/
impl.rs

1use ResultExt;
2
3impl<T, E> ResultExt<T, E> for Result<T, E> {
4    fn contains<U>(&self, x: &U) -> bool where U: PartialEq<T> {
5        match *self {
6            Ok(ref y) => x == y,
7            Err(_) => false
8        }
9    }
10
11    fn contains_err<F>(&self, f: &F) -> bool where F: PartialEq<E> {
12        match *self {
13            Ok(_) => false,
14            Err(ref e) => f == e
15        }
16    }
17
18    #[inline]
19    fn map_or2<U, F: FnOnce(T) -> U>(self, f: F, default: U) -> U {
20        self.map_or(default, f)
21    }
22
23    #[inline]
24    fn map_or_else2<U, F: FnOnce(T) -> U, D: FnOnce(E) -> U>(self, f: F, default: D) -> U {
25        self.map_or_else(default, f)
26    }
27}