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

BitSlice::shift_start and BitSlice::shift_end argument bounds incorrectly documented #250

Open
albertsgarde opened this issue Nov 28, 2023 · 0 comments · May be fixed by #251
Open

BitSlice::shift_start and BitSlice::shift_end argument bounds incorrectly documented #250

albertsgarde opened this issue Nov 28, 2023 · 0 comments · May be fixed by #251

Comments

@albertsgarde
Copy link

albertsgarde commented Nov 28, 2023

The bounds on the by argument for the methods BitSlice::shift_start and BitSlice::shift_end are incorrectly documented.
The documentation states that "This panics if by is not less than self.len()." when in fact it should be "less than or equal", as stated correctly just above.
The assert message has the same error.

The following program shows clearly what the actual behaviour is

use bitvec::array::BitArray;

fn main() {
    let mut array = BitArray::<u8>::new(52);
    print!("{:?}", array);
    let len = array.len();
    array.shift_left(len);
    println!("{:?}", array);
}

I've created PR #251 to fix this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant