[][src]Trait gatherr::IterExt

pub trait IterExt<A, B>: Iterator<Item = Result<A, B>> + Sized {
    fn gatherr<T: FromIterator<A>, E: FromIterator<B>>(self) -> Result<T, E> { ... }
}

An extension trait for iterators of Results to easily collect without the extra newtype

Provided methods

fn gatherr<T: FromIterator<A>, E: FromIterator<B>>(self) -> Result<T, E>

Collect all Ok or Err values from this iterator into a single Result

use gatherr::IterExt;
let v = vec![Ok("a"), Err(1), Ok("b"), Err(2)];

let result: Result<Vec<&str>, Vec<u32>> = v.into_iter().gatherr();

assert_eq!(result, Err(vec![1, 2]));
Loading content...

Implementors

impl<A, B, I: Iterator<Item = Result<A, B>> + Sized> IterExt<A, B> for I[src]

Loading content...