#integer #storing #single #array #binary #masks

smolmask

A small library for storing small binary masks in just a single integer

2 releases

0.1.1 Jul 17, 2023
0.1.0 Jul 17, 2023

#2576 in Algorithms

MIT license

5KB
71 lines

smolmask

Crates.io MIT licensed

Boolean arrays compressed into integers. Useful for storing boolean arrays in databases with just a single integer.

use smolmask::BoolArray;

fn main() {
    let bools = vec![true, false, true, true];
    let integer: u64 = BoolArray::store(&bools).unwrap();
    println!("Integer: {}", integer); // 1096635
    println!("Length: {}", BoolArray::length(integer)); // 4
    println!("{:?}", BoolArray::retrieve(integer)); // [true, false, true, true]
}

Dependencies

~465KB