Struct BoolVec

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

A vector of boolean values.

Implementations§

Source§

impl BoolVec

Source

pub const fn new() -> Self

Creates a new, empty BoolVec. The BoolVec will not allocate until elements are pushed onto it.

Source

pub fn with_capacity(capacity: usize) -> Self

Constructs a new, empty BoolVec with the specified capacity. The BoolVec will be able to hold exactly capacity * 8 booleans without reallocating. If capacity is 0, the BoolVec will not allocate.

Source

pub fn filled_with(count: usize, value: bool) -> Self

Creates a new BoolVec containing count booleans set to value.

Source

pub fn from_vec(vec: Vec<u8>) -> Self

Creates a BitVec from a vector of bytes.

Source

pub fn count(&self) -> usize

Returns the number of booleans that are stored inside of this BoolVec.

Source

pub fn is_empty(&self) -> bool

Is this BoolVec empty ?

Source

pub fn capacity(&self) -> usize

Returns the capacity of this BoolVec, in bytes.

Source

pub fn reserve(&mut self, additional_capacity: usize)

Identical to Vec::reserve.

additional_capacity is in bytes.

Source

pub fn reserve_exact(&mut self, additional_capacity: usize)

Identical to Vec::reserve_exact.

additional_capacity is in bytes.

Source

pub fn shrink_to_fit(&mut self)

Identical to Vec::shrink_to_fit.

Source

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

Shortens the BoolVec, keeping the first count boolean values and dropping the rest.

If count is greater or equal to self.count(), this will have no effect.

Source

pub unsafe fn get_unchecked_ref(&self, nth: usize) -> RefBool<'_>

Gets a reference to the nth boolean stored inside of this BoolVec.

§Safety

No bound checks are made.

Source

pub unsafe fn get_unchecked(&self, nth: usize) -> bool

Gets the nth boolean stored inside of this BoolVec.

§Safety

The value of nth must be less than self.count().

Source

pub fn get_ref(&self, nth: usize) -> Option<RefBool<'_>>

Gets a reference to the nth boolean stored inside of this BoolVec or None if nth is out of bounds.

Source

pub fn get(&self, nth: usize) -> Option<bool>

Gets the the nth boolean stored inside of this BoolVec or None if nth is out of bounds.

Source

pub unsafe fn get_unchecked_mut(&mut self, nth: usize) -> RefBoolMut<'_>

Gets a mutable reference to the nth boolean stored inside of this BoolVec.

§Safety

The value of nth must be less than self.count().

Source

pub fn get_mut(&mut self, nth: usize) -> Option<RefBoolMut<'_>>

Gets a mutable reference to the nth boolean stored inside of this BoolVec or None if nth is out of bounds.

Source

pub unsafe fn set_unchecked(&mut self, nth: usize, value: bool)

Sets the value of the nth boolean stored inside of this BoolVec.

§Safety

The value of nth must be less than self.count()

Source

pub fn set(&mut self, nth: usize, value: bool)

Sets the value of the nth boolean stored inside of this BoolVec.

§Panics

This function panics if nth is greater or equal to self.count().

Source

pub fn push(&mut self, value: bool)

Pushes a new boolean value into this BoolVec.

§Panics

The function panics if the number of bytes allocated overflows usize.

Source

pub fn pop(&mut self) -> Option<bool>

Removes the last boolean value from this BoolVec and returns it.

Source

pub fn last_ref(&self) -> Option<RefBool<'_>>

Gets a reference to the last boolean stored in this BoolVec or None if the BoolVec is empty.

Source

pub fn last_mut(&mut self) -> Option<RefBoolMut<'_>>

Gets a mutable reference to the last boolean stored in this BoolVec or None if the BoolVec is empty.

Source

pub fn last(&self) -> Option<bool>

Gets the last boolean stored in this BoolVec or None if the vetor is empty.

Source

pub fn clear(&mut self)

Clears this BoolVec.1

Source

pub fn iter(&self) -> Iter<'_>

Creates a new iterator that iterates over the values of this BoolVec.

Source

pub fn iter_mut(&mut self) -> IterMut<'_>

Creates a new iterator that iterates over mutable references of the values of this BoolVec.

Source

pub fn bytes(&self) -> impl Iterator<Item = &u8>

Returns an iterator over the bytes of this BoolVec.

Source

pub fn bytes_mut(&mut self) -> impl Iterator<Item = &mut u8>

Returns an iterator over the bytes of this BoolVec.

Source

pub fn count_ones(&self) -> usize

Returns the number of bits that are set to 1 within this vector.

Trait Implementations§

Source§

impl<'s> BitAnd for &'s BoolVec

Source§

type Output = BoolVec

The resulting type after applying the & operator.
Source§

fn bitand(self: &'s BoolVec, other: &'s BoolVec) -> BoolVec

Performs the & operation. Read more
Source§

impl<'s> BitAndAssign<&'s BoolVec> for BoolVec

Source§

fn bitand_assign(&mut self, other: &'s BoolVec)

Performs the &= operation. Read more
Source§

impl<'s> BitOr for &'s BoolVec

Source§

type Output = BoolVec

The resulting type after applying the | operator.
Source§

fn bitor(self: &'s BoolVec, other: &'s BoolVec) -> BoolVec

Performs the | operation. Read more
Source§

impl<'s> BitOrAssign<&'s BoolVec> for BoolVec

Source§

fn bitor_assign(&mut self, other: &'s BoolVec)

Performs the |= operation. Read more
Source§

impl<'s> BitXor for &'s BoolVec

Source§

type Output = BoolVec

The resulting type after applying the ^ operator.
Source§

fn bitxor(self: &'s BoolVec, other: &'s BoolVec) -> BoolVec

Performs the ^ operation. Read more
Source§

impl<'s> BitXorAssign<&'s BoolVec> for BoolVec

Source§

fn bitxor_assign(&mut self, other: &'s BoolVec)

Performs the ^= operation. Read more
Source§

impl Clone for BoolVec

Source§

fn clone(&self) -> BoolVec

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl FromIterator<bool> for BoolVec

Source§

fn from_iter<S: IntoIterator<Item = bool>>(iter: S) -> Self

Creates a value from an iterator. Read more
Source§

impl FromIterator<u8> for BoolVec

Source§

fn from_iter<S: IntoIterator<Item = u8>>(iter: S) -> Self

Creates a value from an iterator. 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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.