Function konst::slice::rchunks_exact

source ·
pub const fn rchunks_exact<T>(
    slice: &[T],
    chunk_size: usize
) -> RChunksExact<'_, T>
Available on crate feature iter only.
Expand description

Const equivalent of <[T]>::rchunks_exact

§Panics

Panics if chunk_size == 0.

§Example

use konst::{option, slice};

const FOUND: [&[u8]; 3] = {
    let iter = slice::rchunks_exact(&[3, 5, 8, 13, 21, 34, 55, 89], 3);
    let (elem0, iter) = option::unwrap!(iter.next());
    let (elem1, iter) = option::unwrap!(iter.next());
    [elem0, elem1, iter.remainder()]
};

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

assert_eq!(FOUND, expected);