#bitmap #bitvec #vec #heap-allocation

smallbitvec

A bit vector optimized for size and inline storage

19 stable releases

2.5.3 Mar 17, 2024
2.5.1 Aug 5, 2021
2.5.0 May 8, 2020
2.4.0 May 15, 2019
1.0.7 Sep 27, 2017

#45 in Data structures

Download history 13559/week @ 2024-07-30 12469/week @ 2024-08-06 17521/week @ 2024-08-13 17566/week @ 2024-08-20 15888/week @ 2024-08-27 17007/week @ 2024-09-03 15495/week @ 2024-09-10 14844/week @ 2024-09-17 16348/week @ 2024-09-24 18615/week @ 2024-10-01 19221/week @ 2024-10-08 17901/week @ 2024-10-15 20057/week @ 2024-10-22 17346/week @ 2024-10-29 19031/week @ 2024-11-05 14565/week @ 2024-11-12

74,400 downloads per month
Used in 17 crates (12 directly)

MIT/Apache

42KB
1K SLoC

smallbitvec

A bit vector that is the size of a pointer, 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