Macro deepmesa_collections::bitvector[][src]

macro_rules! bitvector {
    () => { ... };
    ($($arg:tt)*) => { ... };
    ($item: expr, $len: expr) => { ... };
}
Expand description

A macro to construct a new BitVector from a bit pattern.

This macro accepts a sequence of 1s and 0s separated by commas, (an array of bits effectively) and creates a new BitVector from that pattern. Any token other than a 0 or a 1 will result in a panic.

Examples

use deepmesa::collections::BitVector;
use deepmesa::collections::bitvector;

let bv = bitvector![1,0,1,1,0,1,0,1];
assert_eq!(bv.len(), 8);
assert_eq!(bv.read_u8(0), (0b1011_0101, 8));

The macro can also accept a single bit (1 or 0) and a length and construct a BitVector of that length with the repeating bit.

Examples

use deepmesa::collections::BitVector;
use deepmesa::collections::bitvector;

let bv = bitvector![1;100];
assert_eq!(bv.len(), 100);

Finally this macro can also be used to construct an empty BitVector.

Examples

use deepmesa::collections::BitVector;
use deepmesa::collections::bitvector;

let bv = bitvector!();
assert_eq!(bv.len(), 0);