Trait fallible_iterator::FallibleIterator
[−]
[src]
pub trait FallibleIterator { type Item; type Error; fn next(&mut self) -> Result<Option<Self::Item>, Self::Error>; fn size_hint(&self) -> (usize, Option<usize>) { ... } fn by_ref(&mut self) -> &mut Self where Self: Sized { ... } fn chain<I>(self, it: I) -> Chain<Self, I> where I: IntoFallibleIterator<Item=Self::Item, Error=Self::Error>, Self: Sized { ... } fn cloned<'a, T>(self) -> Cloned<Self> where Self: Sized + FallibleIterator<Item=&'a T>, T: 'a + Clone { ... } fn count(self) -> Result<usize, Self::Error> where Self: Sized { ... } fn collect<T>(self) -> Result<T, Self::Error> where T: FromFallibleIterator<Self::Item>, Self: Sized { ... } fn enumerate(self) -> Enumerate<Self> where Self: Sized { ... } fn fuse(self) -> Fuse<Self> where Self: Sized { ... } fn last(self) -> Result<Option<Self::Item>, Self::Error> where Self: Sized { ... } fn map<B, F>(self, f: F) -> Map<Self, F> where F: FnMut(Self::Item) -> B, Self: Sized { ... } fn nth(&mut self, n: usize) -> Result<Option<Self::Item>, Self::Error> { ... } fn peekable(self) -> Peekable<Self> where Self: Sized { ... } fn rev(self) -> Rev<Self> where Self: Sized + DoubleEndedFallibleIterator { ... } fn take(self, n: usize) -> Take<Self> where Self: Sized { ... } }
An Iterator
-like trait that allows for calculation of items to fail.
Associated Types
Required Methods
fn next(&mut self) -> Result<Option<Self::Item>, Self::Error>
[−]
Advances the iterator and returns the next value.
Returns Ok(None)
when iteration is finished.
The behavior of calling this method after a previous call has returned
Ok(None)
or Err
is implemenetation defined.
Provided Methods
fn size_hint(&self) -> (usize, Option<usize>)
[−]
Returns bounds on the remaining length of the iterator.
Specifically, the first half of the returned tuple is a lower bound and the second half is an upper bound.
For the upper bound, None
indicates that the upper bound is either
unknown or larger than can be represented as a usize
.
Both bounds assume that all remaining calls to next
succeed. That is,
next
could return an Err
in fewer calls than specified by the lower
bound.
The default implementation returns (0, None)
, which is correct for
any iterator.
fn by_ref(&mut self) -> &mut Self where Self: Sized
[−]
Borrow an iterator rather than consuming it.
This is useful to allow the use of iterator adaptors that would otherwise consume the value.
fn chain<I>(self, it: I) -> Chain<Self, I> where I: IntoFallibleIterator<Item=Self::Item, Error=Self::Error>, Self: Sized
[−]
Returns an iterator which yields the elements of this iterator followed by another.
fn cloned<'a, T>(self) -> Cloned<Self> where Self: Sized + FallibleIterator<Item=&'a T>, T: 'a + Clone
[−]
Returns an iterator which clones all of its elements.
fn count(self) -> Result<usize, Self::Error> where Self: Sized
[−]
Consumes the iterator, returning the number of remaining items.
fn collect<T>(self) -> Result<T, Self::Error> where T: FromFallibleIterator<Self::Item>, Self: Sized
[−]
Transforms the iterator into a collection.
An Err
will be returned if any invocation of next
returns Err
.
fn enumerate(self) -> Enumerate<Self> where Self: Sized
[−]
Returns an iterator which yields the current iteration count as well as the value.
fn fuse(self) -> Fuse<Self> where Self: Sized
[−]
Returns an iterator which yields this iterator's elements and ends after
the frist Ok(None)
.
The behavior of calling next
after it has previously returned
Ok(None)
is normally unspecified. The iterator returned by this method
guarantees that Ok(None)
will always be returned.
fn last(self) -> Result<Option<Self::Item>, Self::Error> where Self: Sized
[−]
Returns the last element of the iterator.
fn map<B, F>(self, f: F) -> Map<Self, F> where F: FnMut(Self::Item) -> B, Self: Sized
[−]
Returns an iterator which applies a transform to the elements of the underlying iterator.
fn nth(&mut self, n: usize) -> Result<Option<Self::Item>, Self::Error>
[−]
Returns the n
th element of the iterator.
fn peekable(self) -> Peekable<Self> where Self: Sized
[−]
Returns an iterator that can peek at the next element without consuming it.
fn rev(self) -> Rev<Self> where Self: Sized + DoubleEndedFallibleIterator
[−]
Returns an iterator that yields this iterator's items in the opposite order.
fn take(self, n: usize) -> Take<Self> where Self: Sized
[−]
Returns an iterator that yeilds only the first n
values of this
iterator.
Implementors
impl<'a, I: FallibleIterator + ?Sized> FallibleIterator for &'a mut I
impl<I: FallibleIterator + ?Sized> FallibleIterator for Box<I>
impl<T, U> FallibleIterator for Chain<T, U> where T: FallibleIterator, U: FallibleIterator<Item=T::Item, Error=T::Error>
impl<'a, T, I> FallibleIterator for Cloned<I> where I: FallibleIterator<Item=&'a T>, T: 'a + Clone
impl<T, E, I: Iterator<Item=Result<T, E>>> FallibleIterator for Convert<I>
impl<I> FallibleIterator for Enumerate<I> where I: FallibleIterator
impl<I> FallibleIterator for Fuse<I> where I: FallibleIterator
impl<B, F, I> FallibleIterator for Map<I, F> where I: FallibleIterator, F: FnMut(I::Item) -> B
impl<I> FallibleIterator for Peekable<I> where I: FallibleIterator
impl<I> FallibleIterator for Rev<I> where I: DoubleEndedFallibleIterator
impl<I> FallibleIterator for Take<I> where I: FallibleIterator