[−][src]Trait streaming_iterator::StreamingIterator
An interface for dealing with streaming iterators.
Associated Types
Loading content...Required methods
fn advance(&mut self)
Advances the iterator to the next element.
Iterators start just before the first element, so this should be called before get
.
The behavior of calling this method after the end of the iterator has been reached is unspecified.
fn get(&self) -> Option<&Self::Item>
Returns a reference to the current element of the iterator.
The behavior of calling this method before advance
has been called is unspecified.
Provided methods
fn next(&mut self) -> Option<&Self::Item>
Advances the iterator and returns the next value.
The behavior of calling this method after the end of the iterator has been reached is unspecified.
The default implementation simply calls advance
followed by get
.
fn size_hint(&self) -> (usize, Option<usize>)
Returns the bounds on the remaining length of the iterator.
fn all<F>(&mut self, f: F) -> bool where
Self: Sized,
F: FnMut(&Self::Item) -> bool,
Self: Sized,
F: FnMut(&Self::Item) -> bool,
Determines if all elements of the iterator satisfy a predicate.
fn any<F>(&mut self, f: F) -> bool where
Self: Sized,
F: FnMut(&Self::Item) -> bool,
Self: Sized,
F: FnMut(&Self::Item) -> bool,
Determines if any elements of the iterator satisfy a predicate.
fn by_ref(&mut self) -> &mut Self where
Self: Sized,
Self: Sized,
Borrows an iterator, rather than consuming it.
This is useful to allow the application of iterator adaptors while still retaining ownership of the original adaptor.
fn chain<I>(self, other: I) -> Chain<Self, I> where
Self: Sized,
I: StreamingIterator<Item = Self::Item> + Sized,
Self: Sized,
I: StreamingIterator<Item = Self::Item> + Sized,
Consumes two iterators and returns a new iterator that iterates over both in sequence.
ⓘImportant traits for Cloned<I>fn cloned(self) -> Cloned<Self> where
Self: Sized,
Self::Item: Clone,
Self: Sized,
Self::Item: Clone,
Produces a normal, non-streaming, iterator by cloning the elements of this iterator.
fn count(self) -> usize where
Self: Sized,
Self: Sized,
Consumes the iterator, counting the number of remaining elements and returning it.
fn filter<F>(self, f: F) -> Filter<Self, F> where
Self: Sized,
F: FnMut(&Self::Item) -> bool,
Self: Sized,
F: FnMut(&Self::Item) -> bool,
Creates an iterator which uses a closure to determine if an element should be yielded.
fn filter_map<B, F>(self, f: F) -> FilterMap<Self, B, F> where
Self: Sized,
F: FnMut(&Self::Item) -> Option<B>,
Self: Sized,
F: FnMut(&Self::Item) -> Option<B>,
Creates an iterator which both filters and maps by applying a closure to elements.
fn flat_map<J, F>(self, f: F) -> FlatMap<Self, J, F> where
Self: Sized,
J: StreamingIterator,
F: FnMut(&Self::Item) -> J,
Self: Sized,
J: StreamingIterator,
F: FnMut(&Self::Item) -> J,
Creates an iterator which flattens iterators obtained by applying a closure to elements. Note that the returned iterators must be streaming iterators.
ⓘImportant traits for FilterMapDeref<I, F>fn filter_map_deref<B, F>(self, f: F) -> FilterMapDeref<Self, F> where
Self: Sized,
F: FnMut(&Self::Item) -> Option<B>,
Self: Sized,
F: FnMut(&Self::Item) -> Option<B>,
Creates a regular, non-streaming iterator which both filters and maps by applying a closure to elements.
fn find<F>(&mut self, f: F) -> Option<&Self::Item> where
Self: Sized,
F: FnMut(&Self::Item) -> bool,
Self: Sized,
F: FnMut(&Self::Item) -> bool,
Returns the first element of the iterator that satisfies the predicate.
fn fuse(self) -> Fuse<Self> where
Self: Sized,
Self: Sized,
Creates an iterator which is "well behaved" at the beginning and end of iteration.
The behavior of calling get
before iteration has been started, and of continuing to call
advance
after get
has returned None
is normally unspecified, but this guarantees that
get
will return None
in both cases.
fn inspect<F>(self, f: F) -> Inspect<Self, F> where
F: FnMut(&Self::Item),
Self: Sized,
F: FnMut(&Self::Item),
Self: Sized,
Call a closure on each element, passing the element on.
The closure is called upon calls to advance
or advance_back
, and exactly once per element
regardless of how many times (if any) get
is called.
fn map<B, F>(self, f: F) -> Map<Self, B, F> where
Self: Sized,
F: FnMut(&Self::Item) -> B,
Self: Sized,
F: FnMut(&Self::Item) -> B,
Creates an iterator which transforms elements of this iterator by passing them to a closure.
ⓘImportant traits for MapDeref<I, F>fn map_deref<B, F>(self, f: F) -> MapDeref<Self, F> where
Self: Sized,
F: FnMut(&Self::Item) -> B,
Self: Sized,
F: FnMut(&Self::Item) -> B,
Creates a regular, non-streaming iterator which transforms elements of this iterator by passing them to a closure.
fn map_ref<B: ?Sized, F>(self, f: F) -> MapRef<Self, F> where
Self: Sized,
F: Fn(&Self::Item) -> &B,
Self: Sized,
F: Fn(&Self::Item) -> &B,
Creates an iterator which transforms elements of this iterator by passing them to a closure.
Unlike map
, this method takes a closure that returns a reference into the original value.
fn nth(&mut self, n: usize) -> Option<&Self::Item>
Consumes the first n
elements of the iterator, returning the next one.
ⓘImportant traits for Owned<I>fn owned(self) -> Owned<Self> where
Self: Sized,
Self::Item: ToOwned,
Self: Sized,
Self::Item: ToOwned,
Creates a normal, non-streaming, iterator with elements produced by calling to_owned
on
the elements of this iterator.
Requires the std
feature.
fn position<F>(&mut self, f: F) -> Option<usize> where
Self: Sized,
F: FnMut(&Self::Item) -> bool,
Self: Sized,
F: FnMut(&Self::Item) -> bool,
Returns the index of the first element of the iterator matching a predicate.
fn skip(self, n: usize) -> Skip<Self> where
Self: Sized,
Self: Sized,
Creates an iterator which skips the first n
elements.
fn skip_while<F>(self, f: F) -> SkipWhile<Self, F> where
Self: Sized,
F: FnMut(&Self::Item) -> bool,
Self: Sized,
F: FnMut(&Self::Item) -> bool,
Creates an iterator that skips initial elements matching a predicate.
fn take(self, n: usize) -> Take<Self> where
Self: Sized,
Self: Sized,
Creates an iterator which only returns the first n
elements.
fn take_while<F>(self, f: F) -> TakeWhile<Self, F> where
Self: Sized,
F: FnMut(&Self::Item) -> bool,
Self: Sized,
F: FnMut(&Self::Item) -> bool,
Creates an iterator which only returns initial elements matching a predicate.
fn rev(self) -> Rev<Self> where
Self: Sized + DoubleEndedStreamingIterator,
Self: Sized + DoubleEndedStreamingIterator,
Creates an iterator which returns elemens in the opposite order.
fn fold<B, F>(self, init: B, f: F) -> B where
Self: Sized,
F: FnMut(B, &Self::Item) -> B,
Self: Sized,
F: FnMut(B, &Self::Item) -> B,
Reduces the iterator's elements to a single, final value.
fn for_each<F>(self, f: F) where
Self: Sized,
F: FnMut(&Self::Item),
Self: Sized,
F: FnMut(&Self::Item),
Calls a closure on each element of an iterator.
Implementations on Foreign Types
impl<'a, I: ?Sized> StreamingIterator for &'a mut I where
I: StreamingIterator,
[src]
I: StreamingIterator,
type Item = I::Item
fn advance(&mut self)
[src]
fn get(&self) -> Option<&Self::Item>
[src]
fn size_hint(&self) -> (usize, Option<usize>)
[src]
fn next(&mut self) -> Option<&Self::Item>
[src]
impl<I: ?Sized> StreamingIterator for Box<I> where
I: StreamingIterator,
[src]
I: StreamingIterator,
type Item = I::Item
fn advance(&mut self)
[src]
fn get(&self) -> Option<&Self::Item>
[src]
fn size_hint(&self) -> (usize, Option<usize>)
[src]
fn next(&mut self) -> Option<&Self::Item>
[src]
Implementors
impl<'a, I, T: ?Sized> StreamingIterator for ConvertRef<'a, I, T> where
I: Iterator<Item = &'a T>,
[src]
I: Iterator<Item = &'a T>,
type Item = T
fn advance(&mut self)
[src]
fn get(&self) -> Option<&T>
[src]
fn size_hint(&self) -> (usize, Option<usize>)
[src]
fn count(self) -> usize
[src]
fn fold<Acc, Fold>(self, init: Acc, f: Fold) -> Acc where
Self: Sized,
Fold: FnMut(Acc, &Self::Item) -> Acc,
[src]
Self: Sized,
Fold: FnMut(Acc, &Self::Item) -> Acc,
impl<A, B> StreamingIterator for Chain<A, B> where
A: StreamingIterator,
B: StreamingIterator<Item = A::Item>,
[src]
A: StreamingIterator,
B: StreamingIterator<Item = A::Item>,
type Item = A::Item
fn advance(&mut self)
[src]
fn get(&self) -> Option<&Self::Item>
[src]
fn fold<Acc, F>(self, init: Acc, f: F) -> Acc where
Self: Sized,
F: FnMut(Acc, &Self::Item) -> Acc,
[src]
Self: Sized,
F: FnMut(Acc, &Self::Item) -> Acc,
impl<I> StreamingIterator for Convert<I> where
I: Iterator,
[src]
I: Iterator,
type Item = I::Item
fn advance(&mut self)
[src]
fn get(&self) -> Option<&I::Item>
[src]
fn size_hint(&self) -> (usize, Option<usize>)
[src]
fn count(self) -> usize
[src]
fn fold<Acc, Fold>(self, init: Acc, f: Fold) -> Acc where
Self: Sized,
Fold: FnMut(Acc, &Self::Item) -> Acc,
[src]
Self: Sized,
Fold: FnMut(Acc, &Self::Item) -> Acc,
impl<I> StreamingIterator for Empty<I>
[src]
impl<I> StreamingIterator for Fuse<I> where
I: StreamingIterator,
[src]
I: StreamingIterator,
type Item = I::Item
fn advance(&mut self)
[src]
fn get(&self) -> Option<&I::Item>
[src]
fn size_hint(&self) -> (usize, Option<usize>)
[src]
fn next(&mut self) -> Option<&I::Item>
[src]
fn count(self) -> usize
[src]
fn fold<Acc, Fold>(self, init: Acc, fold: Fold) -> Acc where
Self: Sized,
Fold: FnMut(Acc, &Self::Item) -> Acc,
[src]
Self: Sized,
Fold: FnMut(Acc, &Self::Item) -> Acc,
impl<I> StreamingIterator for Rev<I> where
I: DoubleEndedStreamingIterator,
[src]
I: DoubleEndedStreamingIterator,
type Item = I::Item
fn advance(&mut self)
[src]
fn get(&self) -> Option<&I::Item>
[src]
fn next(&mut self) -> Option<&I::Item>
[src]
fn size_hint(&self) -> (usize, Option<usize>)
[src]
fn fold<Acc, Fold>(self, init: Acc, f: Fold) -> Acc where
Self: Sized,
Fold: FnMut(Acc, &Self::Item) -> Acc,
[src]
Self: Sized,
Fold: FnMut(Acc, &Self::Item) -> Acc,
impl<I> StreamingIterator for Skip<I> where
I: StreamingIterator,
[src]
I: StreamingIterator,
type Item = I::Item
fn advance(&mut self)
[src]
fn get(&self) -> Option<&I::Item>
[src]
fn size_hint(&self) -> (usize, Option<usize>)
[src]
fn fold<Acc, Fold>(self, init: Acc, fold: Fold) -> Acc where
Self: Sized,
Fold: FnMut(Acc, &Self::Item) -> Acc,
[src]
Self: Sized,
Fold: FnMut(Acc, &Self::Item) -> Acc,
impl<I> StreamingIterator for Take<I> where
I: StreamingIterator,
[src]
I: StreamingIterator,
type Item = I::Item
fn advance(&mut self)
[src]
fn get(&self) -> Option<&I::Item>
[src]
fn size_hint(&self) -> (usize, Option<usize>)
[src]
impl<I, B, F> StreamingIterator for FilterMap<I, B, F> where
I: StreamingIterator,
F: FnMut(&I::Item) -> Option<B>,
[src]
I: StreamingIterator,
F: FnMut(&I::Item) -> Option<B>,
type Item = B
fn advance(&mut self)
[src]
fn get(&self) -> Option<&B>
[src]
fn size_hint(&self) -> (usize, Option<usize>)
[src]
fn fold<Acc, Fold>(self, init: Acc, fold: Fold) -> Acc where
Self: Sized,
Fold: FnMut(Acc, &Self::Item) -> Acc,
[src]
Self: Sized,
Fold: FnMut(Acc, &Self::Item) -> Acc,
impl<I, B, F> StreamingIterator for Map<I, B, F> where
I: StreamingIterator,
F: FnMut(&I::Item) -> B,
[src]
I: StreamingIterator,
F: FnMut(&I::Item) -> B,
type Item = B
fn advance(&mut self)
[src]
fn get(&self) -> Option<&B>
[src]
fn size_hint(&self) -> (usize, Option<usize>)
[src]
fn fold<Acc, Fold>(self, init: Acc, fold: Fold) -> Acc where
Self: Sized,
Fold: FnMut(Acc, &Self::Item) -> Acc,
[src]
Self: Sized,
Fold: FnMut(Acc, &Self::Item) -> Acc,
impl<I, B: ?Sized, F> StreamingIterator for MapRef<I, F> where
I: StreamingIterator,
F: Fn(&I::Item) -> &B,
[src]
I: StreamingIterator,
F: Fn(&I::Item) -> &B,
type Item = B
fn advance(&mut self)
[src]
fn get(&self) -> Option<&B>
[src]
fn size_hint(&self) -> (usize, Option<usize>)
[src]
fn next(&mut self) -> Option<&B>
[src]
fn fold<Acc, Fold>(self, init: Acc, fold: Fold) -> Acc where
Self: Sized,
Fold: FnMut(Acc, &Self::Item) -> Acc,
[src]
Self: Sized,
Fold: FnMut(Acc, &Self::Item) -> Acc,
impl<I, F> StreamingIterator for Filter<I, F> where
I: StreamingIterator,
F: FnMut(&I::Item) -> bool,
[src]
I: StreamingIterator,
F: FnMut(&I::Item) -> bool,
type Item = I::Item
fn advance(&mut self)
[src]
fn get(&self) -> Option<&I::Item>
[src]
fn size_hint(&self) -> (usize, Option<usize>)
[src]
fn fold<Acc, Fold>(self, init: Acc, fold: Fold) -> Acc where
Self: Sized,
Fold: FnMut(Acc, &Self::Item) -> Acc,
[src]
Self: Sized,
Fold: FnMut(Acc, &Self::Item) -> Acc,
impl<I, F> StreamingIterator for Inspect<I, F> where
I: StreamingIterator,
F: FnMut(&I::Item),
[src]
I: StreamingIterator,
F: FnMut(&I::Item),
type Item = I::Item
fn advance(&mut self)
[src]
fn get(&self) -> Option<&Self::Item>
[src]
fn size_hint(&self) -> (usize, Option<usize>)
[src]
fn fold<Acc, Fold>(self, init: Acc, fold: Fold) -> Acc where
Self: Sized,
Fold: FnMut(Acc, &Self::Item) -> Acc,
[src]
Self: Sized,
Fold: FnMut(Acc, &Self::Item) -> Acc,
impl<I, F> StreamingIterator for SkipWhile<I, F> where
I: StreamingIterator,
F: FnMut(&I::Item) -> bool,
[src]
I: StreamingIterator,
F: FnMut(&I::Item) -> bool,
type Item = I::Item
fn advance(&mut self)
[src]
fn get(&self) -> Option<&I::Item>
[src]
fn size_hint(&self) -> (usize, Option<usize>)
[src]
fn fold<Acc, Fold>(self, init: Acc, fold: Fold) -> Acc where
Self: Sized,
Fold: FnMut(Acc, &Self::Item) -> Acc,
[src]
Self: Sized,
Fold: FnMut(Acc, &Self::Item) -> Acc,
impl<I, F> StreamingIterator for TakeWhile<I, F> where
I: StreamingIterator,
F: FnMut(&I::Item) -> bool,
[src]
I: StreamingIterator,
F: FnMut(&I::Item) -> bool,
type Item = I::Item
fn advance(&mut self)
[src]
fn get(&self) -> Option<&I::Item>
[src]
fn next(&mut self) -> Option<&I::Item>
[src]
fn size_hint(&self) -> (usize, Option<usize>)
[src]
impl<I, J, F> StreamingIterator for FlatMap<I, J, F> where
I: StreamingIterator,
F: FnMut(&I::Item) -> J,
J: StreamingIterator,
[src]
I: StreamingIterator,
F: FnMut(&I::Item) -> J,
J: StreamingIterator,