Debian Codegraph @

debian/rust-vendor/bitvec/doc/slice/iter/Chunks.md

raw
1 # Shared Bit-Slice Chunking
2
3 This iterator yields successive non-overlapping chunks of a bit-slice. Chunking
4 advances one subslice at a time, starting at the beginning of the bit-slice.
5
6 If the original bit-slice’s length is not evenly divided by the chunk width,
7 then the final chunk will be the remainder, and will be shorter than requested.
8
9 It is created by the [`BitSlice::chunks`] method.
10
11 ## Original
12
13 [`slice::Chunks`](core::slice::Chunks)
14
15 ## Examples
16
17 ```rust
18 use bitvec::prelude::*;
19
20 let bits = bits![0, 0, 0, 1, 1, 1, 0, 1];
21 let mut chunks = bits.chunks(3);
22
23 assert_eq!(chunks.next().unwrap(), bits![0; 3]);
24 assert_eq!(chunks.next().unwrap(), bits![1; 3]);
25 assert_eq!(chunks.next().unwrap(), bits![0, 1]);
26 assert!(chunks.next().is_none());
27 ```
28
29 [`BitSlice::chunks`]: crate::slice::BitSlice::chunks