[][src]Trait libimagerror::iter::TraceIterator

pub trait TraceIterator<T>: Iterator<Item = Result<T, Error>> + Sized {
    fn trace_unwrap(self) -> UnwrapWith<Self, fn(_: Error)> { ... }
fn trace_unwrap_exit(self) -> UnwrapExit<Self, T> { ... }
fn unwrap_with<F>(self, f: F) -> UnwrapWith<Self, F>
    where
        F: FnMut(Error)
, { ... } }

This trait provides methods that make it easier to work with iterators that yield a Result.

Provided methods

Important traits for UnwrapWith<I, F>
fn trace_unwrap(self) -> UnwrapWith<Self, fn(_: Error)>

Creates an iterator that yields the item in each Ok item, while filtering out the Err items. Each filtered Err will be trace-logged with ::trace::trace_error.

As with all iterators, the processing is lazy. If you do not use the result of this method, nothing will be passed to ::trace::trace_error, no matter how many Err items might be present.

Important traits for UnwrapExit<I, T>
fn trace_unwrap_exit(self) -> UnwrapExit<Self, T>

Creates an iterator that yields the item in each Ok item.

The first Err(_) element is traced using ::trace::trace_error_exit.

As with all iterators, the processing is lazy. If you do not use the result of this method, nothing will be passed to ::trace::trace_error_exit, no matter how many Err items might be present.

Important traits for UnwrapWith<I, F>
fn unwrap_with<F>(self, f: F) -> UnwrapWith<Self, F> where
    F: FnMut(Error), 

Takes a closure and creates an iterator that will yield the items inside all Ok items yielded by the original iterator. All Err items will be filtered out, and the contents of each Err will be passed to the closure.

As with all iterators, the processing is lazy. The result of this method must be evaluated for the closure to be called.

Loading content...

Implementors

impl<I, T> TraceIterator<T> for I where
    I: Iterator<Item = Result<T, Error>>, 
[src]

Loading content...