Debian Codegraph @

debian/rust-vendor/bitvec/doc/domain/BitDomain.md

raw
1 # Bit-Slice Partitioning
2
3 This enum partitions a bit-slice into its head- and tail- edge bit-slices, and
4 its interior body bit-slice, according to the definitions laid out in the module
5 documentation.
6
7 It fragments a [`BitSlice`] into smaller `BitSlice`s, and allows the interior
8 bit-slice to become `::Unalias`ed. This is useful when you need to retain a
9 bit-slice view of memory, but wish to remove synchronization costs imposed by a
10 prior call to [`.split_at_mut()`] for as much of the bit-slice as possible.
11
12 ## Why Not `Option`?
13
14 The `Enclave` variant always contains as its single field the exact bit-slice
15 that created the `Enclave`. As such, this type is easily replaceäble with an
16 `Option` of the `Region` variant, which when `None` is understood to be the
17 original.
18
19 This exists as a dedicated enum, even with a technically useless variant, in
20 order to mirror the shape of the element-domain enum. This type should be
21 understood as a shortcut to the end result of splitting by element-domain, then
22 mapping each `PartialElement` and slice back into `BitSlice`s, rather than
23 testing whether a bit-slice can be split on alias boundaries.
24
25 You can get the alternate behavior, of testing whether or not a bit-slice can be
26 split into a `Region` or is unsplittable, by calling `.bit_domain().region()`
27 to produce exactly such an `Option`.
28
29 [`BitSlice`]: crate::slice::BitSlice
30 [`.split_at_mut()`]: crate::slice::BitSlice::split_at_mut