Skip to content

Commit

Permalink
force exhaustion in iter::ArrayChunks::into_remainder
Browse files Browse the repository at this point in the history
  • Loading branch information
krtab committed Apr 3, 2024
1 parent 76cf07d commit ed0f1ce
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion library/core/src/iter/adapters/array_chunks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,20 @@ where
/// Returns an iterator over the remaining elements of the original iterator
/// that are not going to be returned by this iterator. The returned
/// iterator will yield at most `N-1` elements.
///
/// # Example
/// ```
/// # // Also serves as a regression test for https://github.com/rust-lang/rust/issues/123333
/// # #![feature(iter_array_chunks)]
/// let x = [1,2,3,4,5].into_iter().array_chunks::<2>();
/// let mut rem = x.into_remainder().unwrap();
/// assert_eq!(rem.next(), Some(5));
/// assert_eq!(rem.next(), None);
/// ```
#[unstable(feature = "iter_array_chunks", reason = "recently added", issue = "100450")]
#[inline]
pub fn into_remainder(self) -> Option<array::IntoIter<I::Item, N>> {
pub fn into_remainder(mut self) -> Option<array::IntoIter<I::Item, N>> {
while let Some(_) = self.next() {}
self.remainder
}
}
Expand Down

0 comments on commit ed0f1ce

Please sign in to comment.