Debian Codegraph @

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

raw
1 # Exclusive Bit-Slice Exact Chunking
2
3 This iterator yields successive non-overlapping mutable chunks of a bit-slice.
4 Chunking advances one sub-slice at a time, starting at the beginning of the
5 bit-slice.
6
7 If the original bit-slice’s length is not evenly divided by the chunk width,
8 then the leftover segment at the back is not iterated, but can be accessed with
9 the [`.into_remainder()`] or [`.take_remainder()`] methods.
10
11 It is created by the [`BitSlice::chunks_exact_mut`] method.
12
13 ## Original
14
15 [`slice::ChunksExactMut`](core::slice::ChunksExactMut)
16
17 ## API Differences
18
19 This iterator marks all yielded bit-slices as `::Alias`ed.
20
21 ## Examples
22
23 ```rust
24 use bitvec::prelude::*;
25
26 let bits = bits![mut 0, 0, 0, 1, 1, 1, 0, 1];
27 let mut chunks = unsafe {
28 bits.chunks_exact_mut(3).remove_alias()
29 };
30
31 chunks.next().unwrap().fill(true);
32 chunks.next().unwrap().fill(false);
33 assert!(chunks.next().is_none());
34 chunks.take_remainder().copy_from_bitslice(bits![1, 0]);
35 assert!(chunks.take_remainder().is_empty());
36
37 assert_eq!(bits, bits![1, 1, 1, 0, 0, 0, 1, 0]);
38 ```
39
40 [`BitSlice::chunks_exact_mut`]: crate::slice::BitSlice::chunks_exact_mut
41 [`.into_remainder()`]: Self::into_remainder
42 [`.take_remainder()`]: Self::take_remainder