pub struct BoolAdapter<Block, T> { /* private fields */ }Expand description
Adapts a sequence of bools (e.g., &[bool]) to emulate a bit
vector.
In particular, this adapter implements Bits, BitsMut, and
BitsPush as appropriate. It implement PartialEq<T> for all
T: Bits<Block=Block>. It does not, however, implement slicing, so
slice before you adapt.
Note that a bare Vec<bool> or &[bool] already implements Bits,
etc., with a Block type of u8. This means that it is only
compatible with other u8-based bit vectors. BoolAdapter is instead
parametrized by the block type, so it works with bit vectors, slices,
and adapters of any uniform block type.
Implementations§
Source§impl<Block: BlockType, T> BoolAdapter<Block, T>
impl<Block: BlockType, T> BoolAdapter<Block, T>
Sourcepub fn new(bits: T) -> Self
pub fn new(bits: T) -> Self
Creates a new BoolAdapter from an underlying sequence of bools.
Note that the BoolAdapter derefs to the underlying bool sequence.
§Examples
use nostd_bv::BitSliceable;
use nostd_bv::adapter::BoolAdapter;
let array = [0b101usize];
let bv1 = BoolAdapter::new(vec![true, false, true]);
let bv2 = array.bit_slice(0..3);
assert_eq!( bv1, bv2 );Sourcepub fn into_inner(self) -> T
pub fn into_inner(self) -> T
Gets the underlying bool sequence object back out of a BoolAdapter.
Trait Implementations§
Source§impl<'a, Block: BlockType> Bits for BoolAdapter<Block, &'a [bool]>
impl<'a, Block: BlockType> Bits for BoolAdapter<Block, &'a [bool]>
Source§impl<'a, Block: BlockType> Bits for BoolAdapter<Block, &'a mut [bool]>
impl<'a, Block: BlockType> Bits for BoolAdapter<Block, &'a mut [bool]>
Source§impl<'a, Block: BlockType> Bits for BoolAdapter<Block, &'a mut Vec<bool>>
impl<'a, Block: BlockType> Bits for BoolAdapter<Block, &'a mut Vec<bool>>
Source§impl<Block: BlockType> Bits for BoolAdapter<Block, Vec<bool>>
impl<Block: BlockType> Bits for BoolAdapter<Block, Vec<bool>>
Source§impl<'a, Block: BlockType> BitsMut for BoolAdapter<Block, &'a mut [bool]>
impl<'a, Block: BlockType> BitsMut for BoolAdapter<Block, &'a mut [bool]>
Source§impl<'a, Block: BlockType> BitsMut for BoolAdapter<Block, &'a mut Vec<bool>>
impl<'a, Block: BlockType> BitsMut for BoolAdapter<Block, &'a mut Vec<bool>>
Source§impl<Block: BlockType> BitsMut for BoolAdapter<Block, Vec<bool>>
impl<Block: BlockType> BitsMut for BoolAdapter<Block, Vec<bool>>
Source§impl<'a, Block: BlockType> BitsPush for BoolAdapter<Block, &'a mut Vec<bool>>
impl<'a, Block: BlockType> BitsPush for BoolAdapter<Block, &'a mut Vec<bool>>
Source§fn align_block(&mut self, value: bool)
fn align_block(&mut self, value: bool)
value 0 or more times until the size of the bit
vector is block-aligned.Source§fn push_block(&mut self, value: Self::Block)
fn push_block(&mut self, value: Self::Block)
Source§impl<Block: BlockType> BitsPush for BoolAdapter<Block, Vec<bool>>
impl<Block: BlockType> BitsPush for BoolAdapter<Block, Vec<bool>>
Source§fn align_block(&mut self, value: bool)
fn align_block(&mut self, value: bool)
value 0 or more times until the size of the bit
vector is block-aligned.Source§fn push_block(&mut self, value: Self::Block)
fn push_block(&mut self, value: Self::Block)
Source§impl<Block: Clone, T: Clone> Clone for BoolAdapter<Block, T>
impl<Block: Clone, T: Clone> Clone for BoolAdapter<Block, T>
Source§fn clone(&self) -> BoolAdapter<Block, T>
fn clone(&self) -> BoolAdapter<Block, T>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl<Block, T> Deref for BoolAdapter<Block, T>
impl<Block, T> Deref for BoolAdapter<Block, T>
Source§impl<Block, T> DerefMut for BoolAdapter<Block, T>
impl<Block, T> DerefMut for BoolAdapter<Block, T>
Source§impl<Block, T, U> PartialEq<U> for BoolAdapter<Block, T>
impl<Block, T, U> PartialEq<U> for BoolAdapter<Block, T>
Auto Trait Implementations§
impl<Block, T> Freeze for BoolAdapter<Block, T>where
T: Freeze,
impl<Block, T> RefUnwindSafe for BoolAdapter<Block, T>where
T: RefUnwindSafe,
Block: RefUnwindSafe,
impl<Block, T> Send for BoolAdapter<Block, T>
impl<Block, T> Sync for BoolAdapter<Block, T>
impl<Block, T> Unpin for BoolAdapter<Block, T>
impl<Block, T> UnwindSafe for BoolAdapter<Block, T>where
T: UnwindSafe,
Block: UnwindSafe,
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>
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>
self.Source§fn into_bit_not(self) -> BitNot<Self>where
Self: Sized,
fn into_bit_not(self) -> BitNot<Self>where
Self: Sized,
self. Read more