[][src]Macro bitvec::bitvec

macro_rules! bitvec {
    ($order:ty, $store:ident; $val:expr; $rep:expr) => { ... };
    ($order:ty; $val:expr; $rep:expr) => { ... };
    ($val:expr; $rep:expr) => { ... };
    ($($arg:tt)*) => { ... };
}

Construct a BitVec out of a literal array in source code, like vec!.

bitvec! can be invoked in a number of ways. It takes the name of a BitOrder implementation, the name of a BitStore-implementing fundamental, and zero or more fundamentals (integer, floating-point, or boolean) 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.

bitvec! 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!, bitvec! supports bit lists [0, 1, …] and repetition markers [1; n].

Examples

use bitvec::prelude::*;

bitvec![Msb0, u8; 0, 1];
bitvec![Lsb0, u8; 0, 1,];
bitvec![Msb0; 0, 1];
bitvec![Lsb0; 0, 1,];
bitvec![0, 1];
bitvec![0, 1,];
bitvec![Msb0, u8; 1; 5];
bitvec![Lsb0; 0; 5];
bitvec![1; 5];