-
Notifications
You must be signed in to change notification settings - Fork 110
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
copy_within
panics on empty range
#236
Comments
copy_within
panics on empty range
cmrschwarz
added a commit
to cmrschwarz/bitvec
that referenced
this issue
Jul 29, 2023
cmrschwarz
added a commit
to cmrschwarz/bitvec
that referenced
this issue
Jul 29, 2023
cmrschwarz
added a commit
to cmrschwarz/bitvec
that referenced
this issue
Jul 29, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Unlike it's native rust equivalent, this crates'
BitSlice::copy_within
currently panics if called on an empty range, with an empty range, and index 0.For my reading, this violates it's specification which has the sole restriction:
I believe it is fair to say that the range
0..0
is within the bounds of the range0..0
.The panic occurs because
BitSlice::copy_within
callsBitSlice::assert_in_bounds
, which then testsbounds.contains(&index)
, which of course fails.I ran into this edge case in practice, it is very unexpected for the programmer and quite tedious to surround all calls to this function with
if !slice.is_empty() { ... }
.The text was updated successfully, but these errors were encountered: