pub struct BitArray { /* private fields */ }
Implementations§
Source§impl BitArray
impl BitArray
pub fn with_word_size(word_size: usize, len: usize) -> Self
Sourcepub fn set_bit(&mut self, i: usize, b: bool)
pub fn set_bit(&mut self, i: usize, b: bool)
Sets the bit at position i
to b
.
§Examples
let mut ba = fid::BitArray::new(8);
ba.set_bit(3, true);
assert_eq!(ba.get_bit(3), true);
assert_eq!(ba.get_bit(4), false);
ba.set_bit(256, true); // automatically extended
assert_eq!(ba.get_bit(256), true);
Sourcepub fn set_word(&mut self, i: usize, word_size: usize, word: u64)
pub fn set_word(&mut self, i: usize, word_size: usize, word: u64)
Sets the i
-th word of size word_size
to word
.
§Examples
let mut ba = fid::BitArray::new(128);
ba.set_word(0, 12, 0b0101_1010_1100);
assert_eq!(ba.get_word(0, 12), 0b0101_1010_1100);
ba.set_word(5, 12, 0b1010_0101_0011);
assert_eq!(ba.get_word(5, 12), 0b1010_0101_0011);
Sourcepub fn get_slice(&self, i: usize, slice_size: usize) -> u64
pub fn get_slice(&self, i: usize, slice_size: usize) -> u64
Gets the slice of size slice_size
at position i
.
§Panics
Panics if the end position of the slice exceeds the capacity or slice_size
is greater than 64.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for BitArray
impl<'de> Deserialize<'de> for BitArray
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl StructuralPartialEq for BitArray
Auto Trait Implementations§
impl Freeze for BitArray
impl RefUnwindSafe for BitArray
impl Send for BitArray
impl Sync for BitArray
impl Unpin for BitArray
impl UnwindSafe for BitArray
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more