pub struct BitSlice<'a, Block> { /* private fields */ }Expand description
A slice of a bit-vector; akin to &'a [bool] but packed.
§Examples
use bv::*;
let array = [0b00110101u16];
let mut slice = array.bit_slice(..8);
assert_eq!( slice[0], true );
assert_eq!( slice[1], false );
slice = slice.bit_slice(1..8);
assert_eq!( slice[0], false );
assert_eq!( slice[1], true );Implementations§
Source§impl<'a, Block: BlockType> BitSlice<'a, Block>
impl<'a, Block: BlockType> BitSlice<'a, Block>
Sourcepub fn from_slice(blocks: &'a [Block]) -> Self
pub fn from_slice(blocks: &'a [Block]) -> Self
Creates a BitSlice from an array slice of blocks.
The size is always a multiple of
Block::nbits(). If you want a different size, slice.
§Examples
use bv::{BitSlice, BitSliceable};
let v = vec![0b01010011u16, 0u16];
let slice = BitSlice::from_slice(&v).bit_slice(..7);
assert_eq!( slice.len(), 7 );
assert_eq!( slice[0], true );
assert_eq!( slice[1], true );
assert_eq!( slice[2], false );Sourcepub unsafe fn from_raw_parts(bits: *const Block, offset: u64, len: u64) -> Self
pub unsafe fn from_raw_parts(bits: *const Block, offset: u64, len: u64) -> Self
Creates a BitSlice 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.
Trait Implementations§
Source§impl<'a, Block: BlockType> BitSliceable<RangeInclusive<u64>> for BitSlice<'a, Block>
impl<'a, Block: BlockType> BitSliceable<RangeInclusive<u64>> for BitSlice<'a, Block>
Source§impl<'a, Block: BlockType> BitSliceable<RangeToInclusive<u64>> for BitSlice<'a, Block>
impl<'a, Block: BlockType> BitSliceable<RangeToInclusive<u64>> for BitSlice<'a, Block>
Source§impl<'a, Block: BlockType> Bits for BitSlice<'a, Block>
impl<'a, Block: BlockType> Bits for BitSlice<'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 BitSlice<'a, Block>
impl<'a, Block: BlockType> Ord for BitSlice<'a, Block>
Source§impl<'a, Block: BlockType> PartialOrd for BitSlice<'a, Block>
impl<'a, Block: BlockType> PartialOrd for BitSlice<'a, Block>
impl<'a, Block: Copy> Copy for BitSlice<'a, Block>
impl<'a, Block: BlockType> Eq for BitSlice<'a, Block>
Auto Trait Implementations§
impl<'a, Block> Freeze for BitSlice<'a, Block>
impl<'a, Block> RefUnwindSafe for BitSlice<'a, Block>where
Block: RefUnwindSafe,
impl<'a, Block> !Send for BitSlice<'a, Block>
impl<'a, Block> !Sync for BitSlice<'a, Block>
impl<'a, Block> Unpin for BitSlice<'a, Block>
impl<'a, Block> UnwindSafe for BitSlice<'a, Block>where
Block: RefUnwindSafe,
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> 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