Skip to content

Commit

Permalink
add assertion
Browse files Browse the repository at this point in the history
  • Loading branch information
Jujumba committed Jul 15, 2024
1 parent 36107ce commit 4da38dc
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1634,6 +1634,11 @@ impl<B: BitBlock> BitVec<B> {
/// assert!(b.eq_vec(&[true, true, false]));
///```
pub fn insert(&mut self, at: usize, bit: bool) {
assert!(
at <= self.nbits,
"insertion index (is {at}) should be <= nbits (is {len})",
len = self.nbits
);
let mut rem = self.split_off(at);
self.push(bit);
self.append(&mut rem);
Expand Down

0 comments on commit 4da38dc

Please sign in to comment.