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