Function konst::slice::chunks

source ·
pub const fn chunks<T>(slice: &[T], chunk_size: usize) -> Chunks<'_, T>
Expand description

Const equivalent of <[T]>::chunks

§Panics

Panics if chunk_size == 0.

§Example

use konst::iter::collect_const;
use konst::slice;

const CHUNKS: [&[u8]; 3] = collect_const!{&[u8] =>
    slice::chunks(&[3, 5, 8, 13, 21, 34, 55, 89], 3)
};

let expected: &[&[u8]] = &[&[3, 5, 8], &[13, 21, 34], &[55, 89]];

assert_eq!(CHUNKS, expected)