Struct RawBitVec

Source
pub struct RawBitVec { /* private fields */ }
Expand description

§RawBitVec: “Raw Bitwise Vector”

A BitVec where the bit-width and masking data (BitProto) must be manually passed to every function that accesses any element or reallocates the underlying memory.

§Safety

The BitProto passed to the methods of any given instance of RawBitVec MUST be exactly the same as the very first one pased to ANY of its methods that require it. For example, if you create a new instance with RawBitVec::new(), no assumptions are made about the data within and any BitProto is valid. However, if you then use RawBitVec::push(PROTO_3_BITS, 5), you MUST pass PROTO_3_BITS for every other method call on this specific instance that requires a BitProto, for its entire lifetime.

§Pros

  • Same stack-size as Vec (3 usize)
  • Allows for constant-propogation optimizations (IF BitProto supplied to its methods is a constant)
  • No mono-morphization (smaller binary)
  • Can store RawBitVec’s in a homogenous collection (Array, Vec, HashMap, etc.)

§Cons

  • UNSAFE if the same BitProto isnt used for every method call on the same instance of a RawBitVec
  • Clunky API (requires manually passing an extra variable and nearly all methods are unsafe)
  • Cannot truly implement many traits because their signatures don’t allow for a BitProto to be passed
    • Simple psuedo-iterators are provided that do require the same BitProto to be passed

Implementations§

Source§

impl RawBitVec

Source

pub fn len(&self) -> usize

Source

pub unsafe fn cap(&self, proto: BitProto) -> usize

Source

pub unsafe fn free(&self, proto: BitProto) -> usize

Source

pub fn new() -> Self

Source

pub fn with_capacity(proto: BitProto, cap: usize) -> Self

Source

pub unsafe fn grow_exact_for_additional_elements_if_needed( &mut self, proto: BitProto, extra_elements: usize, ) -> Result<(), String>

Source

pub unsafe fn grow_exact_for_total_elements_if_needed( &mut self, proto: BitProto, total_elements: usize, ) -> Result<(), String>

Source

pub unsafe fn grow_for_additional_elements_if_needed( &mut self, proto: BitProto, extra_elements: usize, ) -> Result<(), String>

Source

pub unsafe fn grow_for_total_elements_if_needed( &mut self, proto: BitProto, total_elements: usize, ) -> Result<(), String>

Source

pub fn clear(&mut self)

Source

pub unsafe fn push(&mut self, proto: BitProto, val: usize) -> Result<(), String>

Source

pub unsafe fn push_unchecked(&mut self, proto: BitProto, val: usize)

Source

pub unsafe fn pop(&mut self, proto: BitProto) -> Result<usize, String>

Source

pub unsafe fn pop_unchecked(&mut self, proto: BitProto) -> usize

Source

pub unsafe fn insert( &mut self, proto: BitProto, idx: usize, val: usize, ) -> Result<(), String>

Source

pub unsafe fn insert_unchecked( &mut self, proto: BitProto, idx: usize, val: usize, )

Source

pub unsafe fn insert_bitvec( &mut self, proto: BitProto, insert_idx: usize, bitvec: Self, ) -> Result<(), String>

Source

pub unsafe fn insert_bitvec_unchecked( &mut self, proto: BitProto, insert_idx: usize, bitvec: Self, )

Source

pub unsafe fn insert_iter<II, TO, ESI>( &mut self, proto: BitProto, insert_idx: usize, source: II, ) -> Result<(), String>
where II: IntoIterator<Item = TO, IntoIter = ESI>, TO: ToOwned<Owned = usize>, ESI: ExactSizeIterator + Iterator<Item = TO>,

Source

pub unsafe fn insert_iter_unchecked<II, TO, ESI>( &mut self, proto: BitProto, insert_idx: usize, source: II, )
where II: IntoIterator<Item = TO, IntoIter = ESI>, TO: ToOwned<Owned = usize>, ESI: ExactSizeIterator + Iterator<Item = TO>,

Source

pub unsafe fn remove( &mut self, proto: BitProto, idx: usize, ) -> Result<usize, String>

Source

pub unsafe fn remove_unchecked(&mut self, proto: BitProto, idx: usize) -> usize

Source

pub unsafe fn remove_range( &mut self, proto: BitProto, remove_range: Range<usize>, ) -> Result<Self, String>

Source

pub unsafe fn remove_range_unchecked( &mut self, proto: BitProto, remove_range: Range<usize>, ) -> Self

Source

pub unsafe fn trim_range( &mut self, proto: BitProto, trim_start: RangeFrom<usize>, ) -> Result<Self, String>

Source

pub unsafe fn trim_range_unchecked( &mut self, proto: BitProto, trim_start: RangeFrom<usize>, ) -> Self

Source

pub unsafe fn swap( &mut self, proto: BitProto, idx_a: usize, idx_b: usize, ) -> Result<(), String>

Source

pub unsafe fn swap_unchecked( &mut self, proto: BitProto, idx_a: usize, idx_b: usize, )

Source

pub unsafe fn swap_pop( &mut self, proto: BitProto, idx: usize, ) -> Result<usize, String>

Source

pub unsafe fn swap_pop_unchecked( &mut self, proto: BitProto, idx: usize, ) -> usize

Source

pub unsafe fn trim_excess_capacity( &mut self, proto: BitProto, target_extra_capacity: usize, ) -> Result<(), String>

Source

pub unsafe fn append_bitvec( &mut self, proto: BitProto, bitvec: Self, ) -> Result<(), String>

Source

pub unsafe fn append_bitvec_unchecked(&mut self, proto: BitProto, bitvec: Self)

Source

pub unsafe fn append_iter<II, TO, ESI>( &mut self, proto: BitProto, source: II, ) -> Result<(), String>
where II: IntoIterator<Item = TO, IntoIter = ESI>, TO: ToOwned<Owned = usize>, ESI: ExactSizeIterator + Iterator<Item = TO>,

Source

pub unsafe fn append_iter_unchecked<II, TO, ESI>( &mut self, proto: BitProto, source: II, )
where II: IntoIterator<Item = TO, IntoIter = ESI>, TO: ToOwned<Owned = usize>, ESI: ExactSizeIterator + Iterator<Item = TO>,

Source

pub unsafe fn get(&self, proto: BitProto, idx: usize) -> Result<usize, String>

Source

pub unsafe fn get_unchecked(&self, proto: BitProto, idx: usize) -> usize

Source

pub unsafe fn replace( &mut self, proto: BitProto, idx: usize, val: usize, ) -> Result<usize, String>

Source

pub unsafe fn replace_unchecked( &mut self, proto: BitProto, idx: usize, val: usize, ) -> usize

Source

pub unsafe fn set( &mut self, proto: BitProto, idx: usize, val: usize, ) -> Result<(), String>

Source

pub unsafe fn set_unchecked(&mut self, proto: BitProto, idx: usize, val: usize)

Source

pub fn discard_from_end(&mut self, count: usize)

Source

pub fn drain<'vec>(&'vec mut self) -> RawBitVecDrain<'vec>

Source

pub fn into_iter(self) -> RawBitVecIter

Trait Implementations§

Source§

impl Drop for RawBitVec

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.