Crate bittle[][src]

Expand description

Documentation Crates Actions Status

A library for working with small and cheap bit sets and masks.

The name bittle comes from bit and little.

The bit sets are entirely defined using Copy types in Rust such as u64 or [u128; 4] who’s number of bits define the capacity of the set.

use bittle::FixedSet;
use std::mem;

let mut set = FixedSet::<u64>::empty();


assert_eq!(mem::size_of_val(&set), mem::size_of::<u64>());

The Mask trait can be used to abstract over the read-only side of a bit set. It has useful utilities such as iterating over masked elements through Mask::join.

use bittle::{FixedSet, Mask};

let elements = vec![10, 48, 101];
let mut m = FixedSet::<u128>::empty();

// Since set is empty, no elements are iterated over.
let mut it = m.join(&elements);
assert_eq!(, None);


let mut it = m.join(&elements);
assert_eq!(, Some(&48));
assert_eq!(, None);



Construct a bit set with specific values set.


A fixed size bit set.


The trait for a bit pattern.

A trait used to check if an index is masked.

Basic numerical trait for the plumbing of a bit set. This ensures that only primitive types can be used as the basis of a bit set backed by an array, like [u64; 4] and not [[u32; 2]; 4].


Construct the special mask where every index is set.

Construct the special mask where no index is set.