pub struct Once<T> { /* private fields */ }
Expand description
A simple iterator that returns exactly one item.
Trait Implementations§
Source§impl<T> DoubleEndedStreamingIterator for Once<T>
impl<T> DoubleEndedStreamingIterator for Once<T>
Source§impl<T> DoubleEndedStreamingIteratorMut for Once<T>
impl<T> DoubleEndedStreamingIteratorMut for Once<T>
Source§impl<T> StreamingIterator for Once<T>
impl<T> StreamingIterator for Once<T>
Source§fn get(&self) -> Option<&Self::Item>
fn get(&self) -> Option<&Self::Item>
Returns a reference to the current element of the iterator. Read more
Source§fn size_hint(&self) -> (usize, Option<usize>)
fn size_hint(&self) -> (usize, Option<usize>)
Returns the bounds on the remaining length of the iterator.
Source§fn next(&mut self) -> Option<&Self::Item>
fn next(&mut self) -> Option<&Self::Item>
Advances the iterator and returns the next value. Read more
Source§fn all<F>(&mut self, f: F) -> bool
fn all<F>(&mut self, f: F) -> bool
Determines if all elements of the iterator satisfy a predicate.
Source§fn any<F>(&mut self, f: F) -> bool
fn any<F>(&mut self, f: F) -> bool
Determines if any elements of the iterator satisfy a predicate.
Source§fn 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
Source§fn chain<I>(self, other: I) -> Chain<Self, I>
fn chain<I>(self, other: I) -> Chain<Self, I>
Consumes two iterators and returns a new iterator that iterates over both in sequence.
Source§fn cloned(self) -> Cloned<Self> ⓘ
fn cloned(self) -> Cloned<Self> ⓘ
Produces a normal, non-streaming, iterator by cloning the elements of this iterator.
Source§fn copied(self) -> Copied<Self> ⓘ
fn copied(self) -> Copied<Self> ⓘ
Produces a normal, non-streaming, iterator by copying the elements of this iterator.
Source§fn count(self) -> usizewhere
Self: Sized,
fn count(self) -> usizewhere
Self: Sized,
Consumes the iterator, counting the number of remaining elements and returning it.
Source§fn filter<F>(self, f: F) -> Filter<Self, F>
fn filter<F>(self, f: F) -> Filter<Self, F>
Creates an iterator which uses a closure to determine if an element should be yielded.
Source§fn filter_map<B, F>(self, f: F) -> FilterMap<Self, B, F>
fn filter_map<B, F>(self, f: F) -> FilterMap<Self, B, F>
Creates an iterator which both filters and maps by applying a closure to elements.
Source§fn flat_map<J, F>(self, f: F) -> FlatMap<Self, J, F>
fn flat_map<J, F>(self, f: F) -> FlatMap<Self, J, F>
Creates an iterator which flattens iterators obtained by applying a closure to elements.
Note that the returned iterators must be streaming iterators.
Source§fn filter_map_deref<B, F>(self, f: F) -> FilterMapDeref<Self, F> ⓘ
fn filter_map_deref<B, F>(self, f: F) -> FilterMapDeref<Self, F> ⓘ
Creates a regular, non-streaming iterator which both filters and maps by applying a closure to elements.
Source§fn find<F>(&mut self, f: F) -> Option<&Self::Item>
fn find<F>(&mut self, f: F) -> Option<&Self::Item>
Returns the first element of the iterator that satisfies the predicate.
Source§fn 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
Source§fn inspect<F>(self, f: F) -> Inspect<Self, F>
fn inspect<F>(self, f: F) -> Inspect<Self, F>
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.Source§fn map<B, F>(self, f: F) -> Map<Self, B, F>
fn map<B, F>(self, f: F) -> Map<Self, B, F>
Creates an iterator which transforms elements of this iterator by passing them to a closure.
Source§fn map_deref<B, F>(self, f: F) -> MapDeref<Self, F> ⓘ
fn map_deref<B, F>(self, f: F) -> MapDeref<Self, F> ⓘ
Creates a regular, non-streaming iterator which transforms elements of this iterator by passing them to a closure.
Source§fn map_ref<B: ?Sized, F>(self, f: F) -> MapRef<Self, F>
fn map_ref<B: ?Sized, F>(self, f: F) -> MapRef<Self, F>
Creates an iterator which transforms elements of this iterator by passing them to a closure. Read more
Source§fn 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.Source§fn owned(self) -> Owned<Self> ⓘ
fn owned(self) -> Owned<Self> ⓘ
Creates a normal, non-streaming, iterator with elements produced by calling
to_owned
on
the elements of this iterator. Read moreSource§fn position<F>(&mut self, f: F) -> Option<usize>
fn position<F>(&mut self, f: F) -> Option<usize>
Returns the index of the first element of the iterator matching a predicate.
Source§fn 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.Source§fn skip_while<F>(self, f: F) -> SkipWhile<Self, F>
fn skip_while<F>(self, f: F) -> SkipWhile<Self, F>
Creates an iterator that skips initial elements matching a predicate.
Source§fn 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.Source§fn take_while<F>(self, f: F) -> TakeWhile<Self, F>
fn take_while<F>(self, f: F) -> TakeWhile<Self, F>
Creates an iterator which only returns initial elements matching a predicate.
Source§fn 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.
Source§impl<T> StreamingIteratorMut for Once<T>
impl<T> StreamingIteratorMut for Once<T>
Source§fn 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
Source§fn 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
Source§fn fold_mut<B, F>(self, init: B, f: F) -> B
fn fold_mut<B, F>(self, init: B, f: F) -> B
Reduces the iterator’s mutable elements to a single, final value.
Source§fn for_each_mut<F>(self, f: F)
fn for_each_mut<F>(self, f: F)
Calls a closure on each mutable element of an iterator.
Source§fn map_deref_mut<B, F>(self, f: F) -> MapDerefMut<Self, F> ⓘ
fn map_deref_mut<B, F>(self, f: F) -> MapDerefMut<Self, F> ⓘ
Creates a regular, non-streaming iterator which transforms mutable elements
of this iterator by passing them to a closure.
Auto Trait Implementations§
impl<T> Freeze for Once<T>where
T: Freeze,
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§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more