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

#49 in Data structures

Download history 13630/week @ 2024-06-10 16874/week @ 2024-06-17 16662/week @ 2024-06-24 14719/week @ 2024-07-01 15377/week @ 2024-07-08 14352/week @ 2024-07-15 14036/week @ 2024-07-22 14249/week @ 2024-07-29 12615/week @ 2024-08-05 16822/week @ 2024-08-12 17833/week @ 2024-08-19 17106/week @ 2024-08-26 15584/week @ 2024-09-02 16230/week @ 2024-09-09 14794/week @ 2024-09-16 15716/week @ 2024-09-23

63,335 downloads per month
Used in 11 crates (7 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