Debian Codegraph @

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

raw
1 # Exclusive Bit-Slice Splitting
2
3 This iterator yields successive non-overlapping mutable segments of a bit-slice,
4 separated by bits that match a predicate function. Splitting advances one
5 segment at a time, starting at the beginning of the bit-slice.
6
7 The matched bit **is** included in the yielded segment.
8
9 It is created by the [`BitSlice::split_inclusive_mut`] method.
10
11 ## Original
12
13 [`slice::SplitInclusiveMut`](core::slice::SplitInclusiveMut)
14
15 ## Examples
16
17 ```rust
18 use bitvec::prelude::*;
19
20 let bits = bits![mut 0, 0, 0, 1, 1, 1, 0, 1];
21 let mut split = unsafe {
22 bits.split_inclusive_mut(|idx, _bit| idx % 3 == 2).remove_alias()
23 };
24
25 split.next().unwrap().fill(true);
26 split.next().unwrap().fill(false);
27 split.next().unwrap().copy_from_bitslice(bits![1, 0]);
28 assert!(split.next().is_none());
29
30 assert_eq!(bits, bits![1, 1, 1, 0, 0, 0, 1, 0]);
31 ```
32
33 [`BitSlice::split_inclusive_mut`]: crate::slice::BitSlice::split_inclusive_mut