pub struct Chunks<I: Iterator> { /* private fields */ }Expand description
An iterator-like struct that yields chunks.
This struct is created by chunks method on IterChunks. See its
documentation for more.
Implementations§
Source§impl<I: Iterator> Chunks<I>
impl<I: Iterator> Chunks<I>
Sourcepub fn next(&mut self) -> Option<Chunk<'_, I>>
pub fn next(&mut self) -> Option<Chunk<'_, I>>
Similar to Iterator::next, but not implements Iterator due to
lifetime.
The underlying iterator implementations may choose to resume iteration
after finished, so calling Chunks::next may also return Some(Chunk)
after returning None.
Sourcepub fn for_each(&mut self, f: impl FnMut(Chunk<'_, I>))
pub fn for_each(&mut self, f: impl FnMut(Chunk<'_, I>))
Similar to Iterator::for_each.
use iter_chunks::IterChunks;
let arr = [1, 4, 2, 3, 5];
arr.into_iter().chunks(2).for_each(|chunk| {
assert_eq!(chunk.sum::<i32>(), 5);
});Auto Trait Implementations§
impl<I> Freeze for Chunks<I>where
I: Freeze,
impl<I> RefUnwindSafe for Chunks<I>where
I: RefUnwindSafe,
impl<I> Send for Chunks<I>where
I: Send,
impl<I> Sync for Chunks<I>where
I: Sync,
impl<I> Unpin for Chunks<I>where
I: Unpin,
impl<I> UnwindSafe for Chunks<I>where
I: 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