mirror of
https://github.com/gitbutlerapp/gitbutler.git
synced 2024-12-21 00:21:35 +03:00
13 lines
452 B
Plaintext
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)
|
||
|
})
|
||
|
}
|