Skip to main content

iter_next_chunk_back

Function iter_next_chunk_back 

Source
pub(crate) fn iter_next_chunk_back<T, const N: usize>(
    iter: &mut impl DoubleEndedIterator<Item = T>,
) -> Result<[T; N], IntoIter<T, N>>
Expand description

Pulls N items from the back of iter and returns them as an array. If the iterator yields fewer than N items, Err is returned containing an iterator over the already yielded items.

Since the iterator is passed as a mutable reference and this function calls next_back at most N times, the iterator can still be used afterwards to retrieve the remaining items.

If iter.next_back() panics, all items already yielded by the iterator are dropped.

Used for DoubleEndedIterator::next_chunk_back.