Struct IntoIter

1.36.0 · Source
pub struct IntoIter<T, A: Allocator = Global> { /* private fields */ }
Expand description

An iterator that moves out of a vector.

This struct is created by the into_iter method on Vec (provided by the IntoIterator trait).

§Example

let v = vec![0, 1, 2];
let iter: std::vec::IntoIter<_> = v.into_iter();

Implementations§

Source§

impl<T, A: Allocator> IntoIter<T, A>

1.15.0 · Source

pub fn as_slice(&self) -> &[T]

Returns the remaining items of this iterator as a slice.

§Examples
let vec = vec!['a', 'b', 'c'];
let mut into_iter = vec.into_iter();
assert_eq!(into_iter.as_slice(), &['a', 'b', 'c']);
let _ = into_iter.next().unwrap();
assert_eq!(into_iter.as_slice(), &['b', 'c']);
1.15.0 · Source

pub fn as_mut_slice(&mut self) -> &mut [T]

Returns the remaining items of this iterator as a mutable slice.

§Examples
let vec = vec!['a', 'b', 'c'];
let mut into_iter = vec.into_iter();
assert_eq!(into_iter.as_slice(), &['a', 'b', 'c']);
into_iter.as_mut_slice()[2] = 'z';
assert_eq!(into_iter.next().unwrap(), 'a');
assert_eq!(into_iter.next().unwrap(), 'b');
assert_eq!(into_iter.next().unwrap(), 'z');
Source

pub fn allocator(&self) -> &A

🔬This is a nightly-only experimental API. (allocator_api #32838)

Returns a reference to the underlying allocator.

Trait Implementations§

1.46.0 · Source§

impl<T, A: Allocator> AsRef<[T]> for IntoIter<T, A>

Source§

fn as_ref(&self) -> &[T]

Converts this type into a shared reference of the (usually inferred) input type.
1.8.0 · Source§

impl<T: Clone, A: Allocator + Clone> Clone for IntoIter<T, A>

Source§

fn clone(&self) -> Self

Returns a copy of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
1.13.0 · Source§

impl<T: Debug, A: Allocator> Debug for IntoIter<T, A>

Source§

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

Formats the value using the given formatter. Read more
1.70.0 · Source§

impl<T, A> Default for IntoIter<T, A>
where A: Allocator + Default,

Source§

fn default() -> Self

Creates an empty vec::IntoIter.

let iter: vec::IntoIter<u8> = Default::default();
assert_eq!(iter.len(), 0);
assert_eq!(iter.as_slice(), &[]);
1.0.0 · Source§

impl<T, A: Allocator> DoubleEndedIterator for IntoIter<T, A>

Source§

fn next_back(&mut self) -> Option<T>

Removes and returns an element from the end of the iterator. 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
1.37.0 · Source§

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

Returns the nth element from the end of the iterator. Read more
1.27.0 · Source§

fn try_rfold<B, F, R>(&mut self, init: B, f: F) -> R
where Self: Sized, F: FnMut(B, Self::Item) -> R, R: Try<Output = B>,

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

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

An iterator method that reduces the iterator’s elements to a single, final value, starting from the back. Read more
1.27.0 · 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<T, A: Allocator> Drop for IntoIter<T, A>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
1.0.0 · Source§

impl<T, A: Allocator> ExactSizeIterator for IntoIter<T, A>

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.0.0 · Source§

fn len(&self) -> usize

Returns the exact remaining length of the iterator. Read more
1.0.0 · Source§

impl<T, A: Allocator> Iterator for IntoIter<T, A>

Source§

type Item = T

The type of the elements being iterated over.
Source§

fn next(&mut self) -> Option<T>

Advances the iterator and returns the next value. Read more
Source§

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

Returns the bounds on the remaining length of the 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 count(self) -> usize

Consumes the iterator, counting the number of iterations and returning it. Read more
Source§

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

🔬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
Source§

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

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

fn try_fold<B, F, R>(&mut self, accum: B, f: F) -> R
where Self: Sized, F: FnMut(B, Self::Item) -> R, R: Try<Output = B>,

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

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

Consumes the iterator, returning the last element. Read more
1.0.0 · Source§

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

Returns the nth element of the iterator. Read more
1.28.0 · 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 · Source§

fn chain<U>(self, other: U) -> Chain<Self, <U as IntoIterator>::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 · Source§

fn zip<U>(self, other: U) -> Zip<Self, <U as IntoIterator>::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 adjacent 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 adjacent items of the original iterator. Read more
1.0.0 · 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.21.0 · Source§

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

Calls a closure on each element of an iterator. Read more
1.0.0 · 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 · 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 · 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 · 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 · 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 · 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 · 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 · Source§

fn skip(self, n: usize) -> Skip<Self>
where Self: Sized,

Creates an iterator that skips the first n elements. Read more
1.0.0 ·