Trait libimagerror::iter::TraceIterator
source · pub trait TraceIterator<T>: Iterator<Item = Result<T, Error>> + Sized {
fn trace_unwrap(self) -> UnwrapWith<Self, fn(_: Error)> ⓘ { ... }
fn trace_unwrap_exit(self, exitcode: i32) -> UnwrapExit<Self, T> ⓘ { ... }
fn unwrap_with<F>(self, f: F) -> UnwrapWith<Self, F> ⓘ
where
F: FnMut(Error),
{ ... }
}
Expand description
This trait provides methods that make it easier to work with iterators that yield a Result
.
Provided Methods
sourcefn trace_unwrap(self) -> UnwrapWith<Self, fn(_: Error)> ⓘ
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.
sourcefn trace_unwrap_exit(self, exitcode: i32) -> UnwrapExit<Self, T> ⓘ
fn trace_unwrap_exit(self, exitcode: i32) -> 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.
sourcefn unwrap_with<F>(self, f: F) -> UnwrapWith<Self, F> ⓘwhere
F: FnMut(Error),
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.