contain-rs / bit-set

A Set of Bits
Apache License 2.0
63 stars 25 forks source link

Size of empty bitset is 32 bytes #30

Closed ankushbbbr closed 10 months ago

ankushbbbr commented 11 months ago
let s = BitSet::new();
println!("Size of bitset: {} bytes", std::mem::size_of_val(&s));

The above code gives 32 bytes as the size of empty bitset. Why does an empty bitset need to be 32 bytes? Also, with a bitset of larger capacity, I still get the size as 32 bits. Shouldn't a bitset of capacity 1024 be 1024/8 = 128 bytes ?

let s = BitSet::with_capacity(1024);
println!("Size of bitset: {} bytes", std::mem::size_of_val(&s));