Skip to main content

Take

Struct Take 

1.6.0 ยท Source
pub struct Take<I> { /* private fields */ }
Expand description

An iterator that only iterates over the first n iterations of iter.

This struct is created by the take method on Iterator. See its documentation for more.

Trait Implementationsยง

1.0.0 ยท Sourceยง

impl<I: Clone> Clone for Take<I>

Sourceยง

fn clone(&self) -> Take<I> โ“˜

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) ยท Sourceยง

fn clone_from(&mut self, source: &Self)
where Self:,

Performs copy-assignment from source. Read more
1.0.0 ยท Sourceยง

impl<I: Debug> Debug for Take<I>

Sourceยง

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
1.38.0 ยท Sourceยง

impl<I> DoubleEndedIterator for Take<I>

Sourceยง

fn next_back(&mut self) -> Option<Self::Item>

Removes and returns an element from the end of the iterator. Read more
Sourceยง

fn nth_back(&mut self, n: usize) -> Option<Self::Item>

Returns the nth element from the end of the iterator. Read more
Sourceยง

fn try_rfold<Acc, Fold, R>(&mut self, init: Acc, fold: Fold) -> R
where Self: Sized, Fold: FnMut(Acc, Self::Item) -> R, R: Try<Output = Acc>,

This is the reverse version of Iterator::try_fold(): it takes elements starting from the back of the iterator. Read more
Sourceยง

fn rfold<Acc, Fold>(self, init: Acc, fold: Fold) -> Acc
where Self: Sized, Fold: FnMut(Acc, Self::Item) -> Acc,

An iterator method that reduces the iteratorโ€™s elements to a single, final value, starting from the back. Read more
Sourceยง

fn advance_back_by(&mut self, n: usize) -> Result<(), NonZero<usize>>

๐Ÿ”ฌThis is a nightly-only experimental API. (iter_advance_by #77404)
Advances the iterator from the back by n elements. Read more
Sourceยง

fn next_chunk_back<const N: usize>( &mut self, ) -> Result<[Self::Item; N], IntoIter<Self::Item, N>>
where Self: Sized,

๐Ÿ”ฌThis is a nightly-only experimental API. (iter_next_chunk #98326)
Advances from the back of the iterator and returns an array containing the next N values in sequence. Read more
1.27.0 (const: unstable) ยท Sourceยง

fn rfind<P>(&mut self, predicate: P) -> Option<Self::Item>
where Self: Sized, P: FnMut(&Self::Item) -> bool,

Searches for an element of an iterator from the back that satisfies a predicate. Read more
1.82.0 ยท Sourceยง

impl<T: Clone> DoubleEndedIterator for Take<Repeat<T>>

Sourceยง

fn next_back(&mut self) -> Option<Self::Item>

Removes and returns an element from the end of the iterator. Read more
Sourceยง

fn nth_back(&mut self, n: usize) -> Option<Self::Item>

Returns the nth element from the end of the iterator. Read more
Sourceยง

fn try_rfold<Acc, Fold, R>(&mut self, init: Acc, fold: Fold) -> R
where Self: Sized, Fold: FnMut(Acc, Self::Item) -> R, R: Try<Output = Acc>,

This is the reverse version of Iterator::try_fold(): it takes elements starting from the back of the iterator. Read more
Sourceยง

fn rfold<Acc, Fold>(self, init: Acc, fold: Fold) -> Acc
where Self: Sized, Fold: FnMut(Acc, Self::Item) -> Acc,

An iterator method that reduces the iteratorโ€™s elements to a single, final value, starting from the back. Read more
Sourceยง

fn advance_back_by(&mut self, n: usize) -> Result<(), NonZero<usize>>

๐Ÿ”ฌThis is a nightly-only experimental API. (iter_advance_by #77404)
Advances the iterator from the back by n elements. Read more
Sourceยง

fn next_chunk_back<const N: usize>( &mut self, ) -> Result<[Self::Item; N], IntoIter<Self::Item, N>>
where Self: Sized,

๐Ÿ”ฌThis is a nightly-only experimental API. (iter_next_chunk #98326)
Advances from the back of the iterator and returns an array containing the next N values in sequence. Read more
1.27.0 (const: unstable) ยท Sourceยง

fn rfind<P>(&mut self, predicate: P) -> Option<Self::Item>
where Self: Sized, P: FnMut(&Self::Item) -> bool,

Searches for an element of an iterator from the back that satisfies a predicate. Read more
1.0.0 ยท Sourceยง

impl<I> ExactSizeIterator for Take<I>

1.0.0 ยท Sourceยง

fn len(&self) -> usize

Returns the exact remaining length of the iterator. Read more
Sourceยง

fn is_empty(&self) -> bool

๐Ÿ”ฌThis is a nightly-only experimental API. (exact_size_is_empty #35428)
Returns true if the iterator is empty. Read more
1.82.0 ยท Sourceยง

impl<T: Clone> ExactSizeIterator for Take<Repeat<T>>

Sourceยง

fn len(&self) -> usize

Returns the exact remaining length of the iterator. Read more
Sourceยง

fn is_empty(&self) -> bool

๐Ÿ”ฌThis is a nightly-only experimental API. (exact_size_is_empty #35428)
Returns true if the iterator is empty. Read more
1.82.0 ยท Sourceยง

impl<F: FnMut() -> A, A> ExactSizeIterator for Take<RepeatWith<F>>

Sourceยง

fn len(&self) -> usize

Returns the exact remaining length of the iterator. Read more
Sourceยง

fn is_empty(&self) -> bool

๐Ÿ”ฌThis is a nightly-only experimental API. (exact_size_is_empty #35428)
Returns true if the iterator is empty. Read more
1.26.0 ยท Sourceยง

impl<I> FusedIterator for Take<I>
where I: FusedIterator,

1.0.0 ยท Sourceยง

impl<I> Iterator for Take<I>
where I: Iterator,

Sourceยง

type Item = <I as Iterator>::Item

The type of the elements being iterated over.
Sourceยง

fn next(&mut self) -> Option<<I as Iterator>::Item>

Advances the iterator and returns the next value. Read more
Sourceยง

fn nth(&mut self, n: usize) -> Option<I::Item>

Returns the nth element of the iterator. Read more
Sourceยง

fn size_hint(&self) -> (usize, Option<usize>)

Returns the bounds on the remaining length of the iterator. Read more
Sourceยง

fn try_fold<Acc, Fold, R>(&mut self, init: Acc, fold: Fold) -> R
where Fold: FnMut(Acc, Self::Item) -> R, R: Try<Output = Acc>,

An iterator method that applies a function as long as it returns successfully, producing a single, final value. Read more
Sourceยง

fn fold<B, F>(self, init: B, f: F) -> B
where Self: Sized, F: FnMut(B, Self::Item) -> B,

Folds every element into an accumulator by applying an operation, returning the final result. Read more
Sourceยง

fn for_each<F: FnMut(Self::Item)>(self, f: F)

Calls a closure on each element of an iterator. Read more
Sourceยง

fn advance_by(&mut self, n: usize) -> Result<(), NonZero<usize>>

๐Ÿ”ฌThis is a nightly-only experimental API. (iter_advance_by #77404)
Advances the iterator by n elements. Read more
Sourceยง

fn next_chunk<const N: usize>( &mut self, ) -> Result<[Self::Item; N], IntoIter<Self::Item, N>>
where Self: Sized,

๐Ÿ”ฌThis is a nightly-only experimental API. (iter_next_chunk #98326)
Advances the iterator and returns an array containing the next N values. Read more
1.0.0 (const: unstable) ยท Sourceยง

fn count(self) -> usize
where Self: Sized, Self::Item:,

Consumes the iterator, counting the number of iterations and returning it. Read more
1.0.0 (const: unstable) ยท Sourceยง

fn last(self) -> Option<Self::Item>
where Self: Sized, Self::Item:,

Consumes the iterator, returning the last element. Read more
1.28.0 (const: unstable) ยท Sourceยง

fn step_by(self, step: usize) -> StepBy<Self> โ“˜
where Self: Sized,

Creates an iterator starting at the same point, but stepping by the given amount at each iteration. Read more
1.0.0 (const: unstable) ยท Sourceยง

fn chain<U>(self, other: U) -> Chain<Self, U::IntoIter> โ“˜
where Self: Sized, U: IntoIterator<Item = Self::Item>,

Takes two iterators and creates a new iterator over both in sequence. Read more
1.0.0 (const: unstable) ยท Sourceยง

fn zip<U>(self, other: U) -> Zip<Self, U::IntoIter> โ“˜
where Self: Sized, U: IntoIterator,

โ€˜Zips upโ€™ two iterators into a single iterator of pairs. Read more
Sourceยง

fn intersperse(self, separator: Self::Item) -> Intersperse<Self> โ“˜
where Self: Sized, Self::Item: Clone,

๐Ÿ”ฌThis is a nightly-only experimental API. (iter_intersperse #79524)
Creates a new iterator which places a copy of separator between items of the original iterator. Read more
Sourceยง

fn intersperse_with<G>(self, separator: G) -> IntersperseWith<Self, G> โ“˜
where Self: Sized, G: FnMut() -> Self::Item,

๐Ÿ”ฌThis is a nightly-only experimental API. (iter_intersperse #79524)
Creates a new iterator which places an item generated by separator between items of the original iterator. Read more
1.0.0 (const: unstable) ยท Sourceยง

fn map<B, F>(self, f: F) -> Map<Self, F> โ“˜
where Self: Sized, F: FnMut(Self::Item) -> B,

Takes a closure and creates an iterator which calls that closure on each element. Read more
1.0.0 (const: unstable) ยท Sourceยง

fn filter<P>(self, predicate: P) -> Filter<Self, P> โ“˜
where Self: Sized, P: FnMut(&Self::Item) -> bool,

Creates an iterator which uses a closure to determine if an element should be yielded. Read more
1.0.0 (const: unstable) ยท Sourceยง

fn filter_map<B, F>(self, f: F) -> FilterMap<Self, F> โ“˜
where Self: Sized, F: FnMut(Self::Item) -> Option<B>,

Creates an iterator that both filters and maps. Read more
1.0.0 (const: unstable) ยท Sourceยง

fn enumerate(self) -> Enumerate<Self> โ“˜
where Self: Sized,

Creates an iterator which gives the current iteration count as well as the next value. Read more
1.0.0 (const: unstable) ยท Sourceยง

fn peekable(self) -> Peekable<Self> โ“˜
where Self: Sized,

Creates an iterator which can use the peek and peek_mut methods to look at the next element of the iterator without consuming it. See their documentation for more information. Read more
1.0.0 (const: unstable) ยท Sourceยง

fn skip_while<P>(self, predicate: P) -> SkipWhile<Self, P> โ“˜
where Self: Sized, P: FnMut(&Self::Item) -> bool,

Creates an iterator that skips elements based on a predicate. Read more
1.0.0 (const: unstable) ยท Sourceยง

fn take_while<P>(self, predicate: P) -> TakeWhile<Self, P> โ“˜
where Self: Sized, P: FnMut(&Self::Item) -> bool,

Creates an iterator that yields elements based on a predicate. Read more
1.57.0 (const: unstable) ยท Sourceยง

fn map_while<B, P>(self, predicate: P) -> MapWhile<Self, P> โ“˜
where Self: Sized, P: FnMut(Self::Item) -> Option<B>,

Creates an iterator that both yields elements based on a predicate and maps. Read more
1.0.0 (const: