Trait options_results::ResultIter
[−]
[src]
pub trait ResultIter<T, E>: Iterator<Item = Result<T, E>> where
Self: Sized, { fn unwrap(self) -> Unwrap<Self, T, E> { ... } fn unwrap_or(self, def: T) -> UnwrapOr<Self, T, E> { ... } fn count_ok(self) -> usize { ... } fn count_err(self) -> usize { ... } fn count_ok_err(self) -> (usize, usize) { ... } fn find_ok(&mut self) -> Option<T> { ... } fn find_err(&mut self) -> Option<E> { ... } fn has_ok(&mut self) -> bool { ... } fn has_err(&mut self) -> bool { ... } fn ok_iter(self) -> OkIter<Self, T, E> { ... } fn err_iter(self) -> ErrIter<Self, T, E> { ... } }
Add some methods for the iterator of Result<T, E>
.
Provided Methods
fn unwrap(self) -> Unwrap<Self, T, E>
Create an iterator which yields the unwrapped value as the next value.
(Unwrap<I>::next()
will panic if the value is Err(_)
.)
fn unwrap_or(self, def: T) -> UnwrapOr<Self, T, E>
Create an iterator which yields the unwrapped value or a default as the next value.
fn count_ok(self) -> usize
Count the number of Ok(_)
in this iterator.
fn count_err(self) -> usize
Count the number of Err(_)
in this iterator.
fn count_ok_err(self) -> (usize, usize)
Count the number of Ok(_)
and Err(_)
in this iterator.
Return a tuple as (number of Ok value, number of Err value)
fn find_ok(&mut self) -> Option<T>
Searches for an element of an iterator that the value is Ok(_)
.
If each element of the iterator all equal Err(_)
, it returns None
.
fn find_err(&mut self) -> Option<E>
Searches for an element of an iterator that the value is Err(_)
.
If each element of the iterator all equal Ok(_)
, it returns None
.
fn has_ok(&mut self) -> bool
Tests if any element of the iterator are Ok(_)
.
fn has_err(&mut self) -> bool
Tests if any element of the iterator are Err(_)
.
fn ok_iter(self) -> OkIter<Self, T, E>
Create an iterator which yields unwrapped Ok(_)
value.
fn err_iter(self) -> ErrIter<Self, T, E>
Create an iterator which yields unwrapped Err(_)
value.