1use std::iter::*;
8
9use util::*;
10
11pub use util::Process as Oks;
12pub trait GetOks<T, E> : Sized {
17 fn oks(self) -> FilterMap<Self, fn(Result<T,E>) -> Option<T>>;
18}
19
20impl<T, E, I> GetOks<T, E> for I
21 where I: Iterator<Item = Result<T, E>> + Sized
22{
23 fn oks(self) -> FilterMap<Self, fn(Result<T,E>) -> Option<T>> {
24 self.filter_map(GetOk::get_ok)
25 }
26}
27
28
29#[test]
30fn test_compile() {
31 use std::str::FromStr;
32
33 let _ : Result<_, ::std::num::ParseIntError> = ["1", "2", "3", "4", "5"]
34 .into_iter()
35 .map(|e| usize::from_str(e))
36 .oks()
37 .process(|o| { println!("Ok: {:?}", o); Ok(()) });
38}