Struct streaming_iterator::Once
source · [−]pub struct Once<T> { /* private fields */ }
Expand description
A simple iterator that returns exactly one item.
Trait Implementations
sourceimpl<T> DoubleEndedStreamingIterator for Once<T>
impl<T> DoubleEndedStreamingIterator for Once<T>
sourceimpl<T> DoubleEndedStreamingIteratorMut for Once<T>
impl<T> DoubleEndedStreamingIteratorMut for Once<T>
sourcefn next_back_mut(&mut self) -> Option<&mut Self::Item>
fn next_back_mut(&mut self) -> Option<&mut Self::Item>
Advances the iterator and returns the next mutable value from the back. Read more
sourceimpl<T> StreamingIterator for Once<T>
impl<T> StreamingIterator for Once<T>
type Item = T
type Item = T
The type of the elements being iterated over.
sourcefn get(&self) -> Option<&Self::Item>
fn get(&self) -> Option<&Self::Item>
Returns a reference to the current element of the iterator. Read more
sourcefn size_hint(&self) -> (usize, Option<usize>)
fn size_hint(&self) -> (usize, Option<usize>)
Returns the bounds on the remaining length of the iterator.
sourcefn next(&mut self) -> Option<&Self::Item>
fn next(&mut self) -> Option<&Self::Item>
Advances the iterator and returns the next value. Read more
sourcefn all<F>(&mut self, f: F) -> boolwhere
Self: Sized,
F: FnMut(&Self::Item) -> bool,
fn all<F>(&mut self, f: F) -> boolwhere
Self: Sized,
F: FnMut(&Self::Item) -> bool,
Determines if all elements of the iterator satisfy a predicate.
sourcefn any<F>(&mut self, f: F) -> boolwhere
Self: Sized,
F: FnMut(&Self::Item) -> bool,
fn any<F>(&mut self, f: F) -> boolwhere
Self: Sized,
F: FnMut(&Self::Item) -> bool,
Determines if any elements of the iterator satisfy a predicate.
sourcefn by_ref(&mut self) -> &mut Selfwhere
Self: Sized,
fn by_ref(&mut self) -> &mut Selfwhere
Self: Sized,
Borrows an iterator, rather than consuming it. Read more
sourcefn chain<I>(self, other: I) -> Chain<Self, I>where
Self: Sized,
I: StreamingIterator<Item = Self::Item> + Sized,
fn chain<I>(self, other: I) -> Chain<Self, I>where
Self: Sized,
I: StreamingIterator<Item = Self::Item> + Sized,
Consumes two iterators and returns a new iterator that iterates over both in sequence.
sourcefn count(self) -> usizewhere
Self: Sized,
fn count(self) -> usizewhere
Self: Sized,
Consumes the iterator, counting the number of remaining elements and returning it.
sourcefn filter<F>(self, f: F) -> Filter<Self, F>where
Self: Sized,
F: FnMut(&Self::Item) -> bool,
fn filter<F>(self, f: F) -> Filter<Self, F>where
Self: Sized,
F: FnMut(&Self::Item) -> bool,
Creates an iterator which uses a closure to determine if an element should be yielded.
sourcefn filter_map<B, F>(self, f: F) -> FilterMap<Self, B, F>where
Self: Sized,
F: FnMut(&Self::Item) -> Option<B>,
fn filter_map<B, F>(self, f: F) -> FilterMap<Self, B, F>where
Self: Sized,
F: FnMut(&Self::Item) -> Option<B>,
Creates an iterator which both filters and maps by applying a closure to elements.
sourcefn flat_map<J, F>(self, f: F) -> FlatMap<Self, J, F>where
Self: Sized,
J: StreamingIterator,
F: FnMut(&Self::Item) -> J,
fn flat_map<J, F>(self, f: F) -> FlatMap<Self, J, F>where
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. Read more
sourcefn filter_map_deref<B, F>(self, f: F) -> FilterMapDeref<Self, F>ⓘNotable traits for FilterMapDeref<I, F>impl<I, B, F> Iterator for FilterMapDeref<I, F>where
I: StreamingIterator,
F: FnMut(&I::Item) -> Option<B>, type Item = B;
where
Self: Sized,
F: FnMut(&Self::Item) -> Option<B>,
fn filter_map_deref<B, F>(self, f: F) -> FilterMapDeref<Self, F>ⓘNotable traits for FilterMapDeref<I, F>impl<I, B, F> Iterator for FilterMapDeref<I, F>where
I: StreamingIterator,
F: FnMut(&I::Item) -> Option<B>, type Item = B;
where
Self: Sized,
F: FnMut(&Self::Item) -> Option<B>,
I: StreamingIterator,
F: FnMut(&I::Item) -> Option<B>, type Item = B;
Creates a regular, non-streaming iterator which both filters and maps by applying a closure to elements.
sourcefn find<F>(&mut self, f: F) -> Option<&Self::Item>where
Self: Sized,
F: FnMut(&Self::Item) -> bool,
fn find<F>(&mut self, f: F) -> Option<&Self::Item>where
Self: Sized,
F: FnMut(&Self::Item) -> bool,
Returns the first element of the iterator that satisfies the predicate.
sourcefn fuse(self) -> Fuse<Self>where
Self: Sized,
fn fuse(self) -> Fuse<Self>where
Self: Sized,
Creates an iterator which is “well behaved” at the beginning and end of iteration. Read more
sourcefn inspect<F>(self, f: F) -> Inspect<Self, F>where
F: FnMut(&Self::Item),
Self: Sized,
fn inspect<F>(self, f: F) -> Inspect<Self, F>where
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. Read moresourcefn map<B, F>(self, f: F) -> Map<Self, B, F>where
Self: Sized,
F: FnMut(&Self::Item) -> B,
fn map<B, F>(self, f: F) -> Map<Self, B, F>where
Self: Sized,
F: FnMut(&Self::Item) -> B,
Creates an iterator which transforms elements of this iterator by passing them to a closure.
sourcefn map_deref<B, F>(self, f: F) -> MapDeref<Self, F>ⓘNotable traits for MapDeref<I, F>impl<I, B, F> Iterator for MapDeref<I, F>where
I: StreamingIterator,
F: FnMut(&I::Item) -> B, type Item = B;
where
Self: Sized,
F: FnMut(&Self::Item) -> B,
fn map_deref<B, F>(self, f: F) -> MapDeref<Self, F>ⓘNotable traits for MapDeref<I, F>impl<I, B, F> Iterator for MapDeref<I, F>where
I: StreamingIterator,
F: FnMut(&I::Item) -> B, type Item = B;
where
Self: Sized,
F: FnMut(&Self::Item) -> B,
I: StreamingIterator,
F: FnMut(&I::Item) -> B, type Item = B;
Creates a regular, non-streaming iterator which transforms elements of this iterator by passing them to a closure.
sourcefn map_ref<B: ?Sized, F>(self, f: F) -> MapRef<Self, F>where
Self: Sized,
F: Fn(&Self::Item) -> &B,
fn map_ref<B: ?Sized, F>(self, f: F) -> MapRef<Self, F>where
Self: Sized,
F: Fn(&Self::Item) -> &B,
Creates an iterator which transforms elements of this iterator by passing them to a closure. Read more
sourcefn nth(&mut self, n: usize) -> Option<&Self::Item>
fn nth(&mut self, n: usize) -> Option<&Self::Item>
Consumes the first
n
elements of the iterator, returning the next one.sourcefn position<F>(&mut self, f: F) -> Option<usize>where
Self: Sized,
F: FnMut(&Self::Item) -> bool,
fn position<F>(&mut self, f: F) -> Option<usize>where
Self: Sized,
F: FnMut(&Self::Item) -> bool,
Returns the index of the first element of the iterator matching a predicate.
sourcefn skip(self, n: usize) -> Skip<Self>where
Self: Sized,
fn skip(self, n: usize) -> Skip<Self>where
Self: Sized,
Creates an iterator which skips the first
n
elements.sourcefn skip_while<F>(self, f: F) -> SkipWhile<Self, F>where
Self: Sized,
F: FnMut(&Self::Item) -> bool,
fn skip_while<F>(self, f: F) -> SkipWhile<Self, F>where
Self: Sized,
F: FnMut(&Self::Item) -> bool,
Creates an iterator that skips initial elements matching a predicate.
sourcefn take(self, n: usize) -> Take<Self>where
Self: Sized,
fn take(self, n: usize) -> Take<Self>where
Self: Sized,
Creates an iterator which only returns the first
n
elements.sourcefn take_while<F>(self, f: F) -> TakeWhile<Self, F>where
Self: Sized,
F: FnMut(&Self::Item) -> bool,
fn take_while<F>(self, f: F) -> TakeWhile<Self, F>where
Self: Sized,
F: FnMut(&Self::Item) -> bool,
Creates an iterator which only returns initial elements matching a predicate.
sourcefn rev(self) -> Rev<Self>where
Self: Sized + DoubleEndedStreamingIterator,
fn rev(self) -> Rev<Self>where
Self: Sized + DoubleEndedStreamingIterator,
Creates an iterator which returns elemens in the opposite order.
sourceimpl<T> StreamingIteratorMut for Once<T>
impl<T> StreamingIteratorMut for Once<T>
sourcefn get_mut(&mut self) -> Option<&mut Self::Item>
fn get_mut(&mut self) -> Option<&mut Self::Item>
Returns a mutable reference to the current element of the iterator. Read more
sourcefn next_mut(&mut self) -> Option<&mut Self::Item>
fn next_mut(&mut self) -> Option<&mut Self::Item>
Advances the iterator and returns the next mutable value. Read more
sourcefn fold_mut<B, F>(self, init: B, f: F) -> Bwhere
Self: Sized,
F: FnMut(B, &mut Self::Item) -> B,
fn fold_mut<B, F>(self, init: B, f: F) -> Bwhere
Self: Sized,
F: FnMut(B, &mut Self::Item) -> B,
Reduces the iterator’s mutable elements to a single, final value.
sourcefn for_each_mut<F>(self, f: F)where
Self: Sized,
F: FnMut(&mut Self::Item),
fn for_each_mut<F>(self, f: F)where
Self: Sized,
F: FnMut(&mut Self::Item),
Calls a closure on each mutable element of an iterator.
sourcefn map_deref_mut<B, F>(self, f: F) -> MapDerefMut<Self, F>ⓘNotable traits for MapDerefMut<I, F>impl<I, B, F> Iterator for MapDerefMut<I, F>where
I: StreamingIteratorMut,
F: FnMut(&mut I::Item) -> B, type Item = B;
where
Self: Sized,
F: FnMut(&mut Self::Item) -> B,
fn map_deref_mut<B, F>(self, f: F) -> MapDerefMut<Self, F>ⓘNotable traits for MapDerefMut<I, F>impl<I, B, F> Iterator for MapDerefMut<I, F>where
I: StreamingIteratorMut,
F: FnMut(&mut I::Item) -> B, type Item = B;
where
Self: Sized,
F: FnMut(&mut Self::Item) -> B,
I: StreamingIteratorMut,
F: FnMut(&mut I::Item) -> B, type Item = B;
Creates a regular, non-streaming iterator which transforms mutable elements
of this iterator by passing them to a closure. Read more
Auto Trait Implementations
impl<T> RefUnwindSafe for Once<T>where
T: RefUnwindSafe,
impl<T> Send for Once<T>where
T: Send,
impl<T> Sync for Once<T>where
T: Sync,
impl<T> Unpin for Once<T>where
T: Unpin,
impl<T> UnwindSafe for Once<T>where
T: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more