Macro rfw_utils::BitArr[][src]

macro_rules! BitArr {
    (for $len:expr, in $order:ty, $store:ty $(,)?) => { ... };
    (for $len:expr, in $store:ty $(,)?) => { ... };
    (for $len:expr) => { ... };
}
Expand description

Constructs a type definition for a BitArray.

This macro takes a minimum number of bits, and optionally a set of BitOrder and BitStore implementors, and creates a BitArray type definition that satisfies them. Because this macro is used in type position, it uses PascalCase rather than snake_case for its name.

Grammar

use bitvec::prelude::*;
use core::cell::Cell;

const CENT: usize = bitvec::mem::elts::<usize>(100);
let a: BitArr!(for 100)
  = BitArray::<Lsb0, [usize; CENT]>::zeroed();

let b: BitArr!(for 100, in u32)
  = BitArray::<Lsb0, [u32; 4]>::zeroed();

let c: BitArr!(for 100, in Msb0, Cell<u16>)
  = BitArray::<Msb0, [Cell<u16>; 7]>::zeroed();

The length expression must be a const-expression. It may be a literal or a named const expression. The type arguments have no restrictions, so long as they resolve to valid trait implementors.