File: BitSel.md

package info (click to toggle)
rust-bitvec 1.0.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,780 kB
  • sloc: makefile: 2
file content (28 lines) | stat: -rw-r--r-- 878 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# One-Hot Bit Selection Mask

This type selects exactly one bit in a register. It is a [`BitPos`] shifted from
a counter to a selector, and is used to apply test and write operations to real
memory.

## Type Parameters

- `R`: The register element this selector governs.

## Validity

Values of this type are **required** to have exactly one bit set and all others
cleared. Any other value makes the program incorrect, and will cause memory
corruption.

## Construction

This type is only constructed from `BitPos`, and is always equivalent to
`1 << BitPos`.

The chain of custody from known-good [`BitIdx`] values, through proven-good
[`BitOrder`] implementations, into `BitPos` and then `BitSel` proves that values
of this type are always correct to apply to real memory.

[`BitIdx`]: crate::index::BitIdx
[`BitOrder`]: crate::order::BitOrder
[`BitPos`]: crate::index::BitPos