pub struct BitSliceMut<'a, Block> { /* private fields */ }Expand description
A mutable slice of a bit-vector; akin to &'a mut [bool] but packed.
§Examples
use bv::*;
let mut array = [0b00110101u16];
{
let mut slice = BitSliceMut::from_slice(&mut array);
assert_eq!( slice[0], true );
assert_eq!( slice[1], false );
slice.set_bit(0, false);
}
assert_eq!( array[0], 0b00110100u16 );Implementations§
Source§impl<'a, Block: BlockType> BitSliceMut<'a, Block>
impl<'a, Block: BlockType> BitSliceMut<'a, Block>
Sourcepub fn from_slice(blocks: &mut [Block]) -> Self
pub fn from_slice(blocks: &mut [Block]) -> Self
Creates a BitSliceMut from a mutable array slice of blocks.
The size is always a multiple of Block::nbits(). If you want a different size,
slice.
Sourcepub unsafe fn from_raw_parts(bits: *mut Block, offset: u64, len: u64) -> Self
pub unsafe fn from_raw_parts(bits: *mut Block, offset: u64, len: u64) -> Self
Creates a BitSliceMut from a pointer to its data, an offset where the bits start, and
the number of available bits.
This is unsafe because the size of the passed-in buffer is
not checked. It must hold at least offset + len bits or the resulting behavior is
undefined.
§Precondition
- the first
Block::ceil_div_nbits(len + offset)words ofbitssafe to read and write.
Sourcepub fn as_bit_slice(&self) -> BitSlice<'a, Block>
pub fn as_bit_slice(&self) -> BitSlice<'a, Block>
Converts a mutable bit slice to immutable.
Trait Implementations§
Source§impl<'a, Block: BlockType> BitSliceable<Range<u64>> for BitSliceMut<'a, Block>
impl<'a, Block: BlockType> BitSliceable<Range<u64>> for BitSliceMut<'a, Block>
Source§impl<'a, Block: BlockType> BitSliceable<RangeFrom<u64>> for BitSliceMut<'a, Block>
impl<'a, Block: BlockType> BitSliceable<RangeFrom<u64>> for BitSliceMut<'a, Block>
Source§impl<'a, Block: BlockType> BitSliceable<RangeFull> for BitSliceMut<'a, Block>
impl<'a, Block: BlockType> BitSliceable<RangeFull> for BitSliceMut<'a, Block>
Source§impl<'a, Block: BlockType> BitSliceable<RangeInclusive<u64>> for BitSliceMut<'a, Block>
impl<'a, Block: BlockType> BitSliceable<RangeInclusive<u64>> for BitSliceMut<'a, Block>
Source§type Slice = BitSliceMut<'a, Block>
type Slice = BitSliceMut<'a, Block>
The type of the slice produced.
Source§impl<'a, Block: BlockType> BitSliceable<RangeTo<u64>> for BitSliceMut<'a, Block>
impl<'a, Block: BlockType> BitSliceable<RangeTo<u64>> for BitSliceMut<'a, Block>
Source§impl<'a, Block: BlockType> BitSliceable<RangeToInclusive<u64>> for BitSliceMut<'a, Block>
impl<'a, Block: BlockType> BitSliceable<RangeToInclusive<u64>> for BitSliceMut<'a, Block>
Source§type Slice = BitSliceMut<'a, Block>
type Slice = BitSliceMut<'a, Block>
The type of the slice produced.
Source§impl<'a, Block: BlockType> Bits for BitSliceMut<'a, Block>
impl<'a, Block: BlockType> Bits for BitSliceMut<'a, Block>
Source§impl<'a, Block: BlockType> BitsMut for BitSliceMut<'a, Block>
impl<'a, Block: BlockType> BitsMut for BitSliceMut<'a, Block>
Source§impl<'a, Block: BlockType> Debug for BitSliceMut<'a, Block>
impl<'a, Block: BlockType> Debug for BitSliceMut<'a, Block>
Source§impl<'a, 'b, Block: BlockType> From<&'b BitSliceMut<'a, Block>> for BitSlice<'a, Block>
impl<'a, 'b, Block: BlockType> From<&'b BitSliceMut<'a, Block>> for BitSlice<'a, Block>
Source§fn from(slice: &'b BitSliceMut<'a, Block>) -> Self
fn from(slice: &'b BitSliceMut<'a, Block>) -> Self
Converts to this type from the input type.
Source§impl<'a, Block: BlockType> Ord for BitSliceMut<'a, Block>
impl<'a, Block: BlockType> Ord for BitSliceMut<'a, Block>
Source§impl<'a, Block: BlockType> PartialOrd for BitSliceMut<'a, Block>
impl<'a, Block: BlockType> PartialOrd for BitSliceMut<'a, Block>
impl<'a, Block: BlockType> Eq for BitSliceMut<'a, Block>
Auto Trait Implementations§
impl<'a, Block> Freeze for BitSliceMut<'a, Block>
impl<'a, Block> RefUnwindSafe for BitSliceMut<'a, Block>where
Block: RefUnwindSafe,
impl<'a, Block> !Send for BitSliceMut<'a, Block>
impl<'a, Block> !Sync for BitSliceMut<'a, Block>
impl<'a, Block> Unpin for BitSliceMut<'a, Block>
impl<'a, Block> !UnwindSafe for BitSliceMut<'a, Block>
Blanket Implementations§
Source§impl<T> BitsExt for Twhere
T: Bits,
impl<T> BitsExt for Twhere
T: Bits,
Source§fn bit_concat<Other>(&self, other: Other) -> BitConcat<&Self, Other>
fn bit_concat<Other>(&self, other: Other) -> BitConcat<&Self, Other>
Concatenates two bit vectors, with the bits of
self followed by the bits
of other.Source§fn into_bit_concat<Other>(self, other: Other) -> BitConcat<Self, Other>
fn into_bit_concat<Other>(self, other: Other) -> BitConcat<Self, Other>
Source§fn bit_not(&self) -> BitNot<&Self>
fn bit_not(&self) -> BitNot<&Self>
Returns an object that inverts the values of all the bits in
self.Source§fn into_bit_not(self) -> BitNot<Self>where
Self: Sized,
fn into_bit_not(self) -> BitNot<Self>where
Self: Sized,
Returns an object that inverts the values of all the bits in
self. Read moreSource§fn bit_and<Other>(&self, other: Other) -> BitAnd<&Self, Other>
fn bit_and<Other>(&self, other: Other) -> BitAnd<&Self, Other>
Returns an object that lazily computes the bit-wise conjunction
of two bit-vector-likes. Read more
Source§fn into_bit_and<Other>(self, other: Other) -> BitAnd<Self, Other>
fn into_bit_and<Other>(self, other: Other) -> BitAnd<Self, Other>
Returns an object that lazily computes the bit-wise conjunction
of two bit-vector-likes. Read more
Source§fn bit_or<Other>(&self, other: Other) -> BitOr<&Self, Other>
fn bit_or<Other>(&self, other: Other) -> BitOr<&Self, Other>
Returns an object that lazily computes the bit-wise disjunction
of two bit-vector-likes. Read more
Source§fn into_bit_or<Other>(self, other: Other) -> BitOr<Self, Other>
fn into_bit_or<Other>(self, other: Other) -> BitOr<Self, Other>
Returns an object that lazily computes the bit-wise disjunction
of two bit-vector-likes. Read more
Source§fn bit_xor<Other>(&self, other: Other) -> BitXor<&Self, Other>
fn bit_xor<Other>(&self, other: Other) -> BitXor<&Self, Other>
Returns an object that lazily computes the bit-wise xor of two
bit-vector-likes. Read more
Source§fn into_bit_xor<Other>(self, other: Other) -> BitXor<Self, Other>
fn into_bit_xor<Other>(self, other: Other) -> BitXor<Self, Other>
Returns an object that lazily computes the bit-wise xor of two
bit-vector-likes. Read more
Source§impl<T> BitsMutExt for Twhere
T: BitsMut,
impl<T> BitsMutExt for Twhere
T: BitsMut,
Source§fn bit_assign<T: Bits<Block = Self::Block>>(&mut self, other: T)
fn bit_assign<T: Bits<Block = Self::Block>>(&mut self, other: T)
Source§fn bit_and_assign<T: Bits<Block = Self::Block>>(&mut self, other: T)
fn bit_and_assign<T: Bits<Block = Self::Block>>(&mut self, other: T)
Source§fn bit_or_assign<T: Bits<Block = Self::Block>>(&mut self, other: T)
fn bit_or_assign<T: Bits<Block = Self::Block>>(&mut self, other: T)
Source§fn bit_xor_assign<T: Bits<Block = Self::Block>>(&mut self, other: T)
fn bit_xor_assign<T: Bits<Block = Self::Block>>(&mut self, other: T)
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