[−][src]Struct bitvec_rs::BitVec
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 with_capacity(capacity: usize) -> BitVec
[src]
Constructs an empty BitVec
with the given capacity.
The bit vector will be able to hold at least capacity bits without reallocating. If capacity is 0, the bit vector will not allocate.
pub fn from_bytes(bytes: &[u8]) -> BitVec
[src]
Constructs a BitVec
from bytes.
pub fn from_bools(bools: &[bool]) -> BitVec
[src]
Constructs a BitVec
from bools.
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_bytes(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
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(&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 bitvec.
Trait Implementations
impl Eq for BitVec
[src]
impl Default for BitVec
[src]
impl PartialEq<BitVec> for BitVec
[src]
impl<'_> From<&'_ [bool]> for BitVec
[src]
impl<'_> From<&'_ Vec<bool>> for BitVec
[src]
impl From<Vec<bool>> for BitVec
[src]
impl Clone for BitVec
[src]
fn clone(&self) -> BitVec
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl<'a> IntoIterator for &'a BitVec
[src]
type Item = bool
The type of the elements being iterated over.
type IntoIter = Iter<'a>
Which kind of iterator are we turning this into?
fn into_iter(self) -> Self::IntoIter
[src]
impl IntoIterator for BitVec
[src]
type Item = bool
The type of the elements being iterated over.
type IntoIter = IntoIter
Which kind of iterator are we turning this into?
fn into_iter(self) -> Self::IntoIter
[src]
impl Extend<bool> for BitVec
[src]
fn extend<T>(&mut self, iterable: T) where
T: IntoIterator<Item = bool>,
[src]
T: IntoIterator<Item = bool>,
impl<'a> Extend<&'a bool> for BitVec
[src]
fn extend<T>(&mut self, iterable: T) where
T: IntoIterator<Item = &'a bool>,
[src]
T: IntoIterator<Item = &'a bool>,
impl Display for BitVec
[src]
impl Debug for BitVec
[src]
impl Index<usize> for BitVec
[src]
type Output = bool
The returned type after indexing.
fn index(&self, index: usize) -> &Self::Output
[src]
impl FromIterator<bool> for BitVec
[src]
fn from_iter<T>(iterable: T) -> Self where
T: IntoIterator<Item = bool>,
[src]
T: IntoIterator<Item = bool>,
impl<'a> FromIterator<&'a bool> for BitVec
[src]
fn from_iter<T>(iterable: T) -> Self where
T: IntoIterator<Item = &'a bool>,
[src]
T: IntoIterator<Item = &'a bool>,
Auto Trait Implementations
Blanket Implementations
impl<T, U> Into for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T> From for T
[src]
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<I> IntoIterator for I where
I: Iterator,
[src]
I: Iterator,
type Item = <I as Iterator>::Item
The type of the elements being iterated over.
type IntoIter = I
Which kind of iterator are we turning this into?
fn into_iter(self) -> I
[src]
impl<T, U> TryFrom for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T> Borrow for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> BorrowMut for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,