[][src]Struct ptero::binary::BitVec

pub struct BitVec(_);

Wrapper for Vec<Bit> used for implementing From trait.

Implementations

impl BitVec[src]

pub fn filled_with(bit_val: u8, length: usize) -> BitVec[src]

Constructs a BitVec of given length filled with bit_val.

Arguments

  • bit_val - value that will be set to the Bit
  • length - length of the output vector

Examples

Create a BitVec filled with 8 zero bits

use ptero::binary::{Bit, BitVec};

let vec: Vec<Bit> = BitVec::filled_with(0, 8).into();
assert_eq!(vec, &[Bit(0), Bit(0), Bit(0), Bit(0), Bit(0), Bit(0), Bit(0), Bit(0)]);    

Trait Implementations

impl Debug for BitVec[src]

impl From<Vec<Bit, Global>> for BitVec[src]

impl From<u32> for BitVec[src]

pub fn from(number: u32) -> Self[src]

Conversion implementation for u32. Converts u32 number to the vector of Bits. The result vector has the most significant bit at the beginning.

Examples

Convert the 65 number

use ptero::binary::{Bit, BitVec};

let array: BitVec = vec![1, 0, 1, 1, 1]
                        .iter()
                        .map(|v| Bit(*v))
                        .collect::<Vec<Bit>>()
                        .into();
let number: u32 = array.into();
assert_eq!(number, 23);

Auto Trait Implementations

Blanket Implementations

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

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

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

impl<T> From<T> for T[src]

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

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

type Error = Infallible

The type returned in the event of a conversion error.

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

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

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,