pub struct SProtoBitVec { /* private fields */ }
Expand description
§SProtoBitVec
: “Static Prototype Bitwise Vector”
A BitVec
where the bit-width and masking data (BitProto
) is saved in static reference to the associated BitProto
This is a thin wrapper around RawBitVec
that simply calls the underlying raw method and passes the associated
BitProto
along with it. Unlike RawBitVec
this is safe because it is impossible to ever use the wrong BitProto
§Pros
- Simpler, safer API than
RawBitVec
- No mono-morphization (smaller binary than
CProtoBitVec
) - Can store
SProtoBitVec
’s in a homogenous collection (Array
,Vec
,HashMap
, etc.)
§Cons
- One extra pointer to the static
BitProto
stored in everySProtoBitVec
(4 usize total) - No constant-propogation optimizations
Implementations§
Source§impl SProtoBitVec
impl SProtoBitVec
pub fn len(&self) -> usize
pub fn cap(&self) -> usize
pub fn free(&self) -> usize
pub fn new(proto_ref: &'static BitProto) -> Self
pub fn with_capacity(proto_ref: &'static BitProto, cap: usize) -> Self
pub fn grow_exact_for_additional_elements_if_needed( &mut self, extra_elements: usize, ) -> Result<(), String>
pub fn grow_exact_for_total_elements_if_needed( &mut self, total_elements: usize, ) -> Result<(), String>
pub fn grow_for_additional_elements_if_needed( &mut self, extra_elements: usize, ) -> Result<(), String>
pub fn grow_for_total_elements_if_needed( &mut self, total_elements: usize, ) -> Result<(), String>
pub fn clear(&mut self)
pub fn push(&mut self, val: usize) -> Result<(), String>
pub unsafe fn push_unchecked(&mut self, val: usize)
pub fn pop(&mut self) -> Result<usize, String>
pub unsafe fn pop_unchecked(&mut self) -> usize
pub fn insert(&mut self, idx: usize, val: usize) -> Result<(), String>
pub unsafe fn insert_unchecked(&mut self, idx: usize, val: usize)
pub fn insert_bitvec( &mut self, insert_idx: usize, bitvec: Self, ) -> Result<(), String>
pub unsafe fn insert_bitvec_unchecked( &mut self, insert_idx: usize, bitvec: Self, )
pub fn insert_iter<II, TO, ESI>(
&mut self,
insert_idx: usize,
source: II,
) -> Result<(), String>where
II: IntoIterator<Item = TO, IntoIter = ESI>,
TO: ToOwned<Owned = usize>,
ESI: ExactSizeIterator + Iterator<Item = TO>,
pub unsafe fn insert_iter_unchecked<II, TO, ESI>(
&mut self,
insert_idx: usize,
source: II,
)where
II: IntoIterator<Item = TO, IntoIter = ESI>,
TO: ToOwned<Owned = usize>,
ESI: ExactSizeIterator + Iterator<Item = TO>,
pub fn remove(&mut self, idx: usize) -> Result<usize, String>
pub unsafe fn remove_unchecked(&mut self, idx: usize) -> usize
pub fn remove_range(&mut self, idx_range: Range<usize>) -> Result<Self, String>
pub unsafe fn remove_range_unchecked(&mut self, idx_range: Range<usize>) -> Self
pub fn trim_range( &mut self, idx_range: RangeFrom<usize>, ) -> Result<Self, String>
pub unsafe fn trim_range_unchecked( &mut self, idx_range: RangeFrom<usize>, ) -> Self
pub fn swap(&mut self, idx_a: usize, idx_b: usize) -> Result<(), String>
pub unsafe fn swap_unchecked(&mut self, idx_a: usize, idx_b: usize)
pub fn swap_pop(&mut self, idx: usize) -> Result<usize, String>
pub unsafe fn swap_pop_unchecked(&mut self, idx: usize) -> usize
pub fn trim_excess_capacity( &mut self, extra_capacity_to_keep: usize, ) -> Result<(), String>
pub fn append_bitvec(&mut self, bitvec: Self) -> Result<(), String>
pub unsafe fn append_bitvec_unchecked(&mut self, bitvec: Self)
pub fn append_iter<II, TO, ESI>(&mut self, source: II) -> Result<(), String>where
II: IntoIterator<Item = TO, IntoIter = ESI>,
TO: ToOwned<Owned = usize>,
ESI: ExactSizeIterator + Iterator<Item = TO>,
pub unsafe fn append_iter_unchecked<I, TO>(&mut self, iter: I)
pub fn get(&self, idx: usize) -> Result<usize, String>
pub unsafe fn get_unchecked(&self, idx: usize) -> usize
pub fn replace(&mut self, idx: usize, val: usize) -> Result<usize, String>
pub unsafe fn replace_unchecked(&mut self, idx: usize, val: usize) -> usize
pub fn set(&mut self, idx: usize, val: usize) -> Result<(), String>
pub unsafe fn set_unchecked(&mut self, idx: usize, val: usize)
pub fn discard_from_end(&mut self, count: usize)
pub fn drain<'vec>(&'vec mut self) -> SProtoBitVecDrain<'vec> ⓘ
pub unsafe fn into_raw(self) -> RawBitVec
Trait Implementations§
Source§impl Drop for SProtoBitVec
impl Drop for SProtoBitVec
Auto Trait Implementations§
impl Freeze for SProtoBitVec
impl RefUnwindSafe for SProtoBitVec
impl !Send for SProtoBitVec
impl !Sync for SProtoBitVec
impl Unpin for SProtoBitVec
impl UnwindSafe for SProtoBitVec
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