7 stable releases

3.2.1 Feb 1, 2024
3.2.0 Apr 30, 2022
3.1.0 Apr 30, 2021
2.1.0 Mar 26, 2020
1.0.0 Sep 6, 2019

#56 in Data structures

Download history 150361/week @ 2024-06-12 143960/week @ 2024-06-19 140484/week @ 2024-06-26 136122/week @ 2024-07-03 140315/week @ 2024-07-10 147792/week @ 2024-07-17 152407/week @ 2024-07-24 164341/week @ 2024-07-31 154380/week @ 2024-08-07 150276/week @ 2024-08-14 153165/week @ 2024-08-21 148131/week @ 2024-08-28 168977/week @ 2024-09-04 157372/week @ 2024-09-11 290750/week @ 2024-09-18 229275/week @ 2024-09-25

873,294 downloads per month
Used in 2,045 crates (17 directly)

MPL-2.0+

72KB
2.5K SLoC

bitmaps

A fixed size compact boolean array in Rust.

Overview

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.

Example

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));
}

Documentation

Licence

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/.

Code of Conduct

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.

No runtime deps