Description: BitSet::shrink_to_fit(...) method being applied to a newly created bitset corrupts the internals state of the bit set. The following test demonstrates the problem:
#[test]
fn shrink_new_bit_set() {
let mut set = BitSet::new();
set.shrink_to_fit();
set.contains(1);
}
The last line panics with message "index out of bounds". The cause is that in lib.rs, line 389 the trunc_len is set to 1 if there are no blocks, after truncation the vector of blocks is still empty but the number of bits is set to the size of the single block.
Bug in BitSet::shrink_to_fit method
Crate version: 0.5.2
Description: BitSet::shrink_to_fit(...) method being applied to a newly created bitset corrupts the internals state of the bit set. The following test demonstrates the problem:
The last line panics with message "index out of bounds". The cause is that in lib.rs, line 389 the
trunc_len
is set to 1 if there are no blocks, after truncation the vector of blocks is still empty but the number of bits is set to the size of the single block.