boolvec

Crates.ioboolvec
lib.rsboolvec
version0.2.6
sourcesrc
created_at2020-06-24 16:57:12.199481
updated_at2020-06-28 00:48:58.548335
descriptionA vector of boolean stored contiguously in memory.
homepage
repositoryhttps://github.com/gymore-z/boolvec
max_upload_size
id257623
size53,116
Gymore (gymore-z)

documentation

https://docs.rs/crate/boolvec/0.1.0

README

This crate provides the BoolVec structure. This is basically a wrapper around a Vec<u8> where each byte is interpreted as 8 bool.

Quick Note: Do what you want with this code, I don't really care :)

Example

// Create a new `BoolVec`
use boolvec::BoolVec;

let mut vec = BoolVec::new();

// You can push data onto it
vec.push(true);
vec.push(false);

// ... retreve it
assert_eq!(vec.get(0), Some(true));
assert_eq!(vec.get(3), None);

// ... update it
vec.set(0, false);
assert_eq!(vec.get(0), Some(false));

// You can get a reference to an unaligned boolean.
let mut boolean = vec.get_mut(1).unwrap();
assert_eq!(boolean.get(), false);

boolean.set(true);
assert_eq!(vec.get(1), Some(true));

// You can also iterate over this data (mutably or not).
let mut iter = vec.iter_mut();

iter.next().unwrap().set(true);
iter.next().unwrap().set(false);

let mut iter = vec.iter();

assert_eq!(iter.next(), Some(true));
assert_eq!(iter.next(), Some(false));
assert_eq!(iter.next(), None);
Commit count: 0

cargo fmt