Crate const_chunks

source ·
Expand description

This crate provides an extension trait that lets you chunk iterators into constant-length arrays using const generics.

See the IteratorConstChunks::const_chunks docs for more info.

use const_chunks::IteratorConstChunks;

let mut iter = vec![1, 2, 3, 4, 5].into_iter().const_chunks::<2>();
assert_eq!(iter.next(), Some([1,2]));
assert_eq!(iter.next(), Some([3,4]));
assert_eq!(iter.next(), None);

let mut remainder = iter.into_remainder().unwrap();
assert_eq!(remainder.next(), Some(5));
assert_eq!(remainder.next(), None);

Structs

  • An iterator that iterates over constant-length chunks, where the length is known at compile time.

Traits