[][src]Struct bitvec_rs::BitVec

pub struct BitVec { /* fields omitted */ }

Bit vector with guaranteed [u8] representation and safe mutable access to this slice. Slices into the bit vector are guaranteed to have the unused bits on the last set to 0.

Methods

impl BitVec[src]

pub fn new() -> BitVec[src]

Constructs an empty BitVec.

pub fn from_bytes(bytes: &[u8]) -> BitVec[src]

Constructs a BitVec from bytes.

pub fn from_elem(len: usize, value: bool) -> BitVec[src]

Constructs a BitVec from a repeating bit value.

pub fn as_bytes(&self) -> &[u8][src]

Returns a byte slice view of the data.

pub fn with_bytes_mut<U, F: FnOnce(&mut [u8]) -> U>(&mut self, f: F) -> U[src]

Invokes the given function on a mut byte slice view of the data. After f completes, the trailing unused bits of the last byte are automatically set to 0.

pub fn into_vec(self) -> Vec<u8>[src]

Consumes the self and returns the underlying Vec<u8> of length ceil(self.len()/8). The values of the bits in the last byte of Vec<u8> beyond the length of the BitVec are unspecified.

pub fn len(&self) -> usize[src]

Returns the length of the bit vector.

pub fn is_empty(&self) -> bool[src]

Returns whether the vector is empty.

pub fn get(&self, index: usize) -> Option<bool>[src]

Gets the bit at the given index.

pub fn set(&mut self, index: usize, value: bool)[src]

Sets the bit at the given index. Panics if index exceeds length.

pub fn swap(&mut self, i: usize, j: usize)[src]

Swaps two elements in the BitVec.

pub unsafe fn get_unchecked(&self, index: usize) -> bool[src]

Gets the bit at the given index without bounds checking.

pub unsafe fn set_unchecked(&mut self, index: usize, value: bool)[src]

Sets the bit at the given index without bounds checking.

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

Pushes a boolean to the end of the BitVec.

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

Pops a boolean from the end of the BitVec.

pub fn clear(&mut self)[src]

Clears the BitVec, removing all values.

pub fn capacity(&mut self) -> usize[src]

Returns the number of booleans that the bitvec can hold without reallocating.

pub fn reserve(&mut self, additional: usize)[src]

Reserves capacity for at least additional more booleans to be inserted in the given BitVec. The collection may reserve more space to avoid frequent reallocations.

pub fn truncate(&mut self, len: usize)[src]

Shorten a vector, dropping excess elements.

If len is greater than the vector's current length, this has no effect.

pub fn resize(&mut self, new_len: usize, value: bool)[src]

Reserves capacity for at least additional more booleans to be inserted in the given BitVec. The collection may reserve more space to avoid frequent reallocations.

Important traits for Iter<'a>
pub fn iter(&self) -> Iter[src]

Returns an iterator for the booleans in the array.

Trait Implementations

impl Extend<bool> for BitVec[src]

impl<'a> Extend<&'a bool> for BitVec[src]

impl PartialEq<BitVec> for BitVec[src]

impl Default for BitVec[src]

impl Clone for BitVec[src]

fn clone_from(&mut self, source: &Self)
1.0.0
[src]

Performs copy-assignment from source. Read more

impl Eq for BitVec[src]

impl Display for BitVec[src]

impl Debug for BitVec[src]

impl Index<usize> for BitVec[src]

type Output = bool

The returned type after indexing.

Auto Trait Implementations

impl Send for BitVec

impl Sync for BitVec

Blanket Implementations

impl<T, U> Into for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T> From for T[src]

impl<T, U> TryFrom for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> BorrowMut for T where
    T: ?Sized
[src]

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.