Debian Codegraph @

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

raw
1 # Bit-Slice Windowing
2
3 This iterator yields successive overlapping windows into a bit-slice. Windowing
4 advances one bit at a time, so for any given window width `N`, most bits will
5 appear in `N` windows. Windows do not “extend” past either edge of the
6 bit-slice: the first window has its front edge at the front of the bit-slice,
7 and the last window has its back edge at the back of the bit-slice.
8
9 It is created by the [`BitSlice::windows`] method.
10
11 ## Original
12
13 [`slice::Windows`](core::slice::Windows)
14
15 ## Examples
16
17 ```rust
18 use bitvec::prelude::*;
19
20 let bits = bits![0, 0, 1, 1, 0];
21 let mut windows = bits.windows(2);
22 let expected = &[
23 bits![0, 0],
24 bits![0, 1],
25 bits![1, 1],
26 bits![1, 0],
27 ];
28
29 assert_eq!(windows.len(), 4);
30 for (window, expected) in windows.zip(expected) {
31 assert_eq!(window, expected);
32 }
33 ```
34
35 [`BitSlice::windows`]: crate::slice::BitSlice::windows