Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/bodil/bitmaps
Bitmap types for Rust
https://github.com/bodil/bitmaps
Last synced: about 12 hours ago
JSON representation
Bitmap types for Rust
- Host: GitHub
- URL: https://github.com/bodil/bitmaps
- Owner: bodil
- License: mpl-2.0
- Created: 2019-09-06T16:15:34.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2024-02-01T19:12:11.000Z (11 months ago)
- Last Synced: 2024-12-15T13:05:39.280Z (8 days ago)
- Language: Rust
- Size: 61.5 KB
- Stars: 49
- Watchers: 5
- Forks: 15
- Open Issues: 9
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# 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
```rust
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
* [API docs](https://docs.rs/bitmaps)
## 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][coc]. By participating in this project you agree to abide by its
terms.[sized-chunks]: https://github.com/bodil/sized-chunks
[coc]: https://github.com/bodil/bitmaps/blob/master/CODE_OF_CONDUCT.md