macro_rules! bits {
($order:ident, $store:ident; $($val:expr),* $(,)?) => { ... };
($order:path, $store:ident; $($val:expr),* $(,)?) => { ... };
($order:ident; $($val:expr),* $(,)?) => { ... };
($order:path; $($val:expr),* $(,)?) => { ... };
($($val:expr),* $(,)?) => { ... };
($order:ident, $store:ident; $val:expr; $len:expr) => { ... };
($order:path, $store:ident; $val:expr; $len:expr) => { ... };
($order:ident; $val:expr; $len:expr) => { ... };
($order:path; $val:expr; $len:expr) => { ... };
($val:expr; $len:expr) => { ... };
}Expand description
Construct a &BitSlice out of a literal array in source code, like vec!.
bits! can be invoked in a number of ways. It takes the name of a BitOrder
implementation, the name of a BitStore-implementing fundamental (which must be
one of u8, u16, u32, or u64), and zero or more fundamentals (integer,
floating-point) which are used to build the bits. Each fundamental literal
corresponds to one bit, and is considered to represent 1 if it is any other
value than exactly zero.
bits! can be invoked with no specifiers, a BitOrder specifier, or a
BitOrder and a BitStore specifier. It cannot be invoked with a BitStore
specifier but no BitOrder specifier, due to overlap in how those tokens are
matched by the macro system.
Like vec!, bits! supports bit lists [0, 1, …] and repetition markers
[1; n].
Examples
use bitvec::prelude::*;
bits![Msb0, u8; 0, 1];
bits![Lsb0, u8; 0, 1,];
bits![Msb0; 0, 1];
bits![Lsb0; 0, 1,];
bits![0, 1];
bits![0, 1,];
bits![0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 0, 0, 0];
bits![Msb0, u8; 1; 5];
bits![Lsb0; 0; 5];
bits![1; 5];
bits![Local; 0, 1,];