9 releases

new 0.3.3 Feb 17, 2025
0.3.2 Feb 15, 2025
0.3.0 Nov 17, 2024
0.2.3 Oct 26, 2024
0.1.0 Jul 2, 2024

#1045 in Data structures

Download history 20/week @ 2024-10-28 18/week @ 2024-11-04 24/week @ 2024-11-11 92/week @ 2024-11-18 5/week @ 2024-11-25 9/week @ 2024-12-09 3/week @ 2025-02-03 167/week @ 2025-02-10

170 downloads per month

MIT license

29KB
607 lines

bitvek

Crates.io Documentation License: MIT

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?

Quick Start

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:

// requires the total number of bits to be a multiple of 8
let vec = bitvec![0b11110000, 0b00001111];

Memory Efficiency

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.


lib.rs:

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?

Quick Start

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:

#
// requires the total number of bits to be a multiple of 8
let vec = bitvec![0b11110000, 0b00001111];

Memory Efficiency

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.

No runtime deps