Debian Codegraph @

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

raw
1 # Constructor Macros
2
3 This module provides macros that can be used to create `bitvec` data buffers at
4 compile time. Each data structure has a corresponding macro:
5
6 - `BitSlice` has [`bits!`]
7 - `BitArray` has [`bitarr!`] (and [`BitArr!`] to produce type expressions)
8 - `BitBox` has [`bitbox!`]
9 - `BitVec` has [`bitvec!`]
10
11 These macros take a sequence of bit literals, as well as some optional control
12 prefixes, and expand to code that is generally solvable at compile-time. The
13 provided bit-orderings `Lsb0` and `Msb0` have implementations that can be used
14 in `const` contexts, while third-party user-provided orderings cannot be used in
15 `const` contexts but almost certainly *can* be const-folded by LLVM.
16
17 The sequences are encoded into element literals during compilation, and will be
18 correctly encoded into the target binary. This is even true for targets with
19 differing byte-endianness than the host compiler.
20
21 See each macro for documentation on its invocation syntax. The general pattern
22 is `[modifier] [T, O;] bits…`. The modifiers influence the nature of the
23 produced binding, the `[T, O;]` pair provides type parameters when the default
24 is undesirable, and the `bits…` provides the actual contents of the data
25 buffer.
26
27 [`BitArr!`]: macro@crate::BitArr
28 [`bitarr!`]: macro@crate::bitarr
29 [`bitbox!`]: macro@crate::bitbox
30 [`bits!`]: macro@crate::bits
31 [`bitvec!`]: macro@crate::bitvec