Debian Codegraph @

debian/rust-vendor/bitvec/doc/slice/BitSliceIndex.md

raw
1 # Bit-Slice Indexing
2
3 This trait, like its mirror in `core`, unifies various types that can be used to
4 index within a bit-slice. Individual `usize` indices can refer to exactly one
5 bit within a bit-slice, and `R: RangeBounds<usize>` ranges can refer to
6 subslices of any length within a bit-slice.
7
8 The three operations (get, get unchecked, and index) reflect the three theories
9 of lookup within a collection: fallible, pre-checked, and crashing on failure.
10
11 You will likely not use this trait directly; its methods all have corresponding
12 methods on [`BitSlice`] that delegate to particular implementations of it.
13
14 ## Original
15
16 [`slice::SliceIndex`](core::slice::SliceIndex)
17
18 ## API Differences
19
20 The [`SliceIndex::Output`] type is not usable here, because `bitvec` cannot
21 manifest a `&mut bool` reference. Work to unify referential values in the trait
22 system is ongoing, and in the future this functionality *may* be approximated.
23
24 Instead, this uses two output types, [`Immut`] and [`Mut`], that are the
25 referential structures produced by indexing immutably or mutably, respectively.
26 This allows the range implementations to produce `&/mut BitSlice` as expected,
27 while `usize` produces the proxy structure.
28
29 [`Immut`]: Self::Immut
30 [`Mut`]: Self::Mut
31 [`SliceIndex::Output`]: core::slice::SliceIndex::Output