1 stable release
1.0.0 | Jul 31, 2025 |
---|
#182 in No standard library
88 downloads per month
Used in 5 crates
(via fimg)
13KB
194 lines
Adds array_chunks
on stable.
This used to be a nightly feature, now its a crate.
This is just a wrapper so you dont have to write x.as_chunks::<N>().0.into_iter()
.
After array_chunks was brutally taken from us in #143289, I have taken it upon myself to diligently add it back to rust.
An iterator over a slice in (non-overlapping) chunks (N
elements at a time), starting at the beginning of the slice.
use array_chunks::*;
let slice = ['l', 'o', 'r', 'e', 'm'];
let mut iter = slice.array_chunks::<2>();
assert_eq!(iter.next(), Some(&['l', 'o']));
assert_eq!(iter.next(), Some(&['r', 'e']));
assert_eq!(iter.next(), None);