gitbutler/crates/gitbutler-changeset/tests/fixtures/code4.txt
2024-04-04 13:53:03 +02:00

13 lines
452 B
Plaintext

fn chunk_bytes<'a, const N: usize>(bytes: &'a [u8]) -> impl Iterator<Item = BitArray<N>> + '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)
})
}