Macro bitvec::bits[][src]

macro_rules! bits {
    (mut $order:ident, $store:ident; $($val:expr),* $(,)?) => { ... };
    (mut $order:path, $store:ident; $($val:expr),* $(,)?) => { ... };
    (mut $order:ident; $($val:expr),* $(,)?) => { ... };
    (mut $order:path; $($val:expr),* $(,)?) => { ... };
    (mut $($val:expr),* $(,)?) => { ... };
    (mut $order:ident, $store:ident; $val:expr; $len:expr) => { ... };
    (mut $order:path, $store:ident; $val:expr; $len:expr) => { ... };
    (mut $order:ident; $val:expr; $len:expr) => { ... };
    (mut $order:path; $val:expr; $len:expr) => { ... };
    (mut $val:expr; $len:expr) => { ... };
    ($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) => { ... };
}

Constructs a BitSlice handle 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 core type (which can be any of the fundamental integers, their Cell wrappers, or their Atomic sibling types), and zero or more expressions which are used to build the bits. Each value expression corresponds to one bit. If the expression evaluates to 0, it is the zero bit; otherwise, it is the 1 bit.

bits! can be invoked with no type specifiers, a BitOrder specifier only, or both a BitOrder and a BitStore specifier. It cannot be invoked with a BitStore but no BitOrder, as the macro grammar is incapable of distinguishing between these two.

In addition, a mut marker may be used as the first argument to produce an &mut BitSlice handle instead of a &BitSlice handle.

Like vec!, bits! supports bit lists [0, 1, …] and repetition markers [1; n].

Examples

use bitvec::prelude::*;

bits![Msb0, u8; 0, 1];
bits![mut Lsb0, u8; 0, 1,];
bits![Msb0; 0, 1];
bits![mut Lsb0; 0, 1,];
bits![0, 1];
bits![mut 0, 1,];
bits![0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 0, 0, 0];
bits![Msb0, u8; 1; 5];
bits![mut Lsb0; 0; 5];
bits![1; 5];
bits![mut LocalBits; 0, 1,];