pub trait FallibleIterator {
    type Item;
    type Error: Error;

    // Required method
    fn next(&mut self) -> Result<Option<Self::Item>, Self::Error>;

    // Provided method
    fn collect<B>(self) -> Result<B, Self::Error>
       where B: FromIterator<Self::Item>,
             Self: Sized { ... }
}
Expand description

Variation of the Iterator trait where each read can fail.

Required Associated Types§

source

type Item

Type of items returned by this iterator.

source

type Error: Error

Type of errors that can occur when reading from this iterator.

Required Methods§

source

fn next(&mut self) -> Result<Option<Self::Item>, Self::Error>

Advances the iterator and returns the next value.

§Errors

May fail depending on the implementation.

Provided Methods§

source

fn collect<B>(self) -> Result<B, Self::Error>
where B: FromIterator<Self::Item>, Self: Sized,

Transforms an iterator into a collection.

§Errors

This consumes the iterator and reads from it. If any read fails, the result is the first error encountered.

Implementors§