1 | use OptionExt; |
---|---|
2 | |
3 | impl<T> OptionExt<T> for Option<T> { |
4 | fn contains<U>(&self, x: &U) -> bool where U: PartialEq<T> { |
5 | match *self { |
6 | Some(ref y: &T) => x == y, |
7 | None => false, |
8 | } |
9 | } |
10 | |
11 | #[inline] |
12 | fn map_or2<U, F: FnOnce(T) -> U>(self, f: F, default: U) -> U { |
13 | self.map_or(default, f) |
14 | } |
15 | |
16 | #[inline] |
17 | fn map_or_else2<U, F: FnOnce(T) -> U, D: FnOnce() -> U>(self, f: F, default: D) -> U { |
18 | self.map_or_else(default, f) |
19 | } |
20 | } |
21 |