Crates.io | bitmaps |
lib.rs | bitmaps |
version | 3.2.1 |
source | src |
created_at | 2019-09-06 16:14:56.535961 |
updated_at | 2024-02-01 19:11:58.66657 |
description | Fixed size boolean arrays |
homepage | |
repository | https://github.com/bodil/bitmaps |
max_upload_size | |
id | 162820 |
size | 93,613 |
A fixed size compact boolean array in Rust.
This crate provides a convenient and efficient way of declaring and working with
fixed size bitmaps in Rust. It was originally split out from the sized-chunks
crate and its primary purpose is to support it, but the Bitmap
type has proven
to be generally useful enough that it was split off into a separate crate.
use bitmaps::Bitmap;
fn main() {
let mut bitmap = Bitmap::<10>::new();
assert_eq!(bitmap.set(5, true), false);
assert_eq!(bitmap.set(5, true), true);
assert_eq!(bitmap.get(5), true);
assert_eq!(bitmap.get(6), false);
assert_eq!(bitmap.len(), 1);
assert_eq!(bitmap.set(3, true), false);
assert_eq!(bitmap.len(), 2);
assert_eq!(bitmap.first_index(), Some(3));
assert_eq!(bitmap.last_index(), Some(5));
}
Copyright 2019 Bodil Stokke
This software is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms.