fn chunk_bytes<'a, const N: usize>(bytes: &'a [u8]) -> impl Iterator> + 'a { bytes .chunks(N) .map(|chunk| { // Create a new byte array of size N and copy the chunk into it, // padding with zeros if the chunk is shorter than N. let mut padded_chunk = [0; N]; padded_chunk[..chunk.len()].copy_from_slice(chunk); BitArray::new(padded_chunk) }) }