bitvec icon indicating copy to clipboard operation
bitvec copied to clipboard

Bug: as_raw_slice() returns wrong value

Open BorMor opened this issue 2 years ago • 0 comments

Hello. I have found problem with method BitSlice::as_raw_slice(), it returns wrong value is some scenarios

System: 6.1.1-arch1-1 GNU/Linux rustc -V: rustc 1.66.0 (69f9c33d7 2022-12-12)

[dependencies]
bitvec = "1.0.1"
let bv = bitvec![u8, Lsb0; 1, 1, 1, 0, 1];

let s2 = &bv[2..5];
assert_eq!(s2, bitvec![u8, Lsb0; 1, 0, 1]);
let sbv2 = s2.to_bitvec();
assert_eq!(sbv2, bitvec![u8, Lsb0; 1, 0, 1]);

// panic here
// but left must be 5 [1, 0, 1]
assert_eq!(sbv2.as_raw_slice(), &[5u8]); // <--  left: `[20]`, right: `[5]`'

BorMor avatar Jan 04 '23 13:01 BorMor