Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,23 @@ impl FixedBitSet {
}
}

/// Disable `bit`.
///
/// **Panics** if **bit** is out of bounds.
#[inline]
pub fn remove(&mut self, bit: usize) {
assert!(
bit < self.length,
"remove at index {} exceeds fixbitset size {}",
bit,
self.length
);
let (block, i) = div_rem(bit);
unsafe {
*self.data.get_unchecked_mut(block) &= !(1 << i);
}
}

/// Enable `bit`, and return its previous value.
///
/// **Panics** if **bit** is out of bounds.
Expand All @@ -236,6 +253,7 @@ impl FixedBitSet {
prev
}
}

/// Toggle `bit` (inverting its state).
///
/// ***Panics*** if **bit** is out of bounds
Expand All @@ -252,6 +270,7 @@ impl FixedBitSet {
*self.data.get_unchecked_mut(block) ^= 1 << i;
}
}

/// **Panics** if **bit** is out of bounds.
#[inline]
pub fn set(&mut self, bit: usize, enabled: bool) {
Expand Down