#bitvec #bitmap #vec

smallbitvec

A bit vector optimized for size and inline storage

17 stable releases

Uses old Rust 2015

2.5.1 Aug 5, 2021
2.5.0 May 8, 2020
2.4.0 May 15, 2019
2.3.0 Dec 6, 2018
1.0.7 Sep 27, 2017

#107 in Data structures

Download history 4720/week @ 2023-06-06 3777/week @ 2023-06-13 4148/week @ 2023-06-20 4685/week @ 2023-06-27 4379/week @ 2023-07-04 5117/week @ 2023-07-11 7471/week @ 2023-07-18 6920/week @ 2023-07-25 8783/week @ 2023-08-01 7576/week @ 2023-08-08 9319/week @ 2023-08-15 8473/week @ 2023-08-22 5609/week @ 2023-08-29 4755/week @ 2023-09-05 4831/week @ 2023-09-12 5446/week @ 2023-09-19

22,163 downloads per month
Used in 7 crates (5 directly)

MIT/Apache

42KB
1K SLoC

smallbitvec

A bit vector that is only one word wide, and can store data either inline or on the heap. Like the bit-vec crate but optimized for small inline size and reduced allocations.


lib.rs:

SmallBitVec is a bit vector, a vector of single-bit values stored compactly in memory.

SmallBitVec grows dynamically, like the standard Vec<T> type. It can hold up to about one word of bits inline (without a separate heap allocation). If the number of bits exceeds this inline capacity, it will allocate a buffer on the heap.

Example

use smallbitvec::SmallBitVec;

let mut v = SmallBitVec::new();
v.push(true);
v.push(false);

assert_eq!(v[0], true);
assert_eq!(v[1], false);

No runtime deps