| Crates.io | bitvek |
| lib.rs | bitvek |
| version | 0.3.8 |
| created_at | 2024-07-02 23:29:16.856039+00 |
| updated_at | 2025-08-20 15:27:23.285498+00 |
| description | A simple bit vector implementation. |
| homepage | |
| repository | https://github.com/Lingxuan-Ye/bitvek |
| max_upload_size | |
| id | 1290018 |
| size | 57,244 |
Say, we have a bit vector —
it's nothing better than a Vec<bool>, but …
what if we implement it,
and save some poor bits of memory?
use bitvek::bitvec;
let vec = bitvec![
true, true, true, true, false, false, false, false,
false, false, false, false, true, true, true, true,
];
Find it cumbersome? Try this:
// The total number of bits must be a multiple of 8.
let vec = bitvec![0b11110000, 0b00001111];
To achieve memory savings, the total number of bits stored must exceed twice the machine word size in bytes, corresponding to 8 for 32-bit systems and 16 for 64-bit systems.