Crates.io | smolmask |
lib.rs | smolmask |
version | 0.1.1 |
source | src |
created_at | 2023-07-17 14:19:00.29607 |
updated_at | 2023-07-17 14:20:39.578341 |
description | A small library for storing small binary masks in just a single integer. |
homepage | |
repository | |
max_upload_size | |
id | 918538 |
size | 8,467 |
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]
}