Debian Codegraph @

debian/rust-vendor/bitvec/doc/macros/make_elem.md

raw
1 # Element Encoder Macro
2
3 This macro is invoked by `__encode_bits!` with a set of bits that exactly fills
4 some `BitStore` element type. It is responsible for encoding those bits into the
5 raw memory bytes and assembling them into a whole integer.
6
7 It works by inspecting the `$order` argument. If it is one of `LocalBits`,
8 `Lsb0`, or `Msb0`, then it can do the construction in-place, and get solved
9 during `const` evaluation. If it is any other ordering, then it emits runtime
10 code to do the translation and defers to the optimizer for evaluation.
11
12 It divides the input into clusters of eight bit expressions, then uses the
13 `$order` argument to choose whether the bits are accumulated into a `u8` using
14 `Lsb0`, `Msb0`, or `LocalBits` ordering. The accumulated byte array is then
15 converted into an integer using the corresponding `uN::from_{b,l,n}e_bytes`
16 function in `__ty_from_bytes!`.
17
18 Once assembled, the raw integer is changed into the requested final type. This
19 currently routes through a helper type that unifies `const fn` constructors for
20 each of the raw integer fundamentals, cells, and atomics in order to avoid
21 transmutes.