pub trait GetErrors<T, E>: Sized {
// Required method
fn errors(self) -> FilterMap<Self, fn(_: Result<T, E>) -> Option<E>>;
}
Expand description
Extension trait for Iterator<Item = Result<T, E>>
to get all E
s
Required Methods§
Sourcefn errors(self) -> FilterMap<Self, fn(_: Result<T, E>) -> Option<E>>
fn errors(self) -> FilterMap<Self, fn(_: Result<T, E>) -> Option<E>>
Get all errors from this Iterator
use std::str::FromStr;
use resiter::GetErrors;
let res: Vec<std::num::ParseIntError> = ["1", "2", "a", "4", "b"]
.iter()
.map(|e| usize::from_str(e))
.errors()
.collect();
assert_eq!(res.len(), 2);
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.