| 1 |
# Exclusive Bit-Slice Chunking |
| 2 |
|
| 3 |
This iterator yields successive non-overlapping mutable chunks of a bit-slice. |
| 4 |
Chunking advances one subslice at a time, starting at the end 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_mut`] method. |
| 10 |
|
| 11 |
## Original |
| 12 |
|
| 13 |
[`slice::ChunksMut`](core::slice::ChunksMut) |
| 14 |
|
| 15 |
## API Differences |
| 16 |
|
| 17 |
This iterator marks all yielded bit-slices as `::Alias`ed. |
| 18 |
|
| 19 |
## Examples |
| 20 |
|
| 21 |
```rust |
| 22 |
use bitvec::prelude::*; |
| 23 |
|
| 24 |
let bits = bits![mut 0, 1, 0, 0, 0, 1, 1, 1]; |
| 25 |
let mut chunks = unsafe { |
| 26 |
bits.rchunks_mut(3).remove_alias() |
| 27 |
}; |
| 28 |
|
| 29 |
chunks.next().unwrap().fill(false); |
| 30 |
chunks.next().unwrap().fill(true); |
| 31 |
chunks.next().unwrap().copy_from_bitslice(bits![1, 0]); |
| 32 |
assert!(chunks.next().is_none()); |
| 33 |
|
| 34 |
assert_eq!(bits, bits![1, 0, 1, 1, 1, 0, 0, 0]); |
| 35 |
``` |
| 36 |
|
| 37 |
[`BitSlice::chunks_mut`]: crate::slice::BitSlice::chunks_mut |