Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: as_raw_slice() returns wrong value #208

Open
BorMor opened this issue Jan 4, 2023 · 0 comments
Open

Bug: as_raw_slice() returns wrong value #208

BorMor opened this issue Jan 4, 2023 · 0 comments

Comments

@BorMor
Copy link

BorMor commented Jan 4, 2023

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]`'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant