pub fn from_bytes(slice: &[u8]) -> Vob<usize> {
        let new_len = slice.len().checked_mul(8).expect("Overflow detected");
        let mut v = Vob::with_capacity(new_len);
        for i in 0..blocks_required::<usize>(new_len) {
            let mut w = usize::zero();
            for j in 0..bytes_per_block::<usize>() {
                let off = i * bytes_per_block::<usize>() + j;
                if off >= slice.len() {
                    // If slice doesn't contain a whole number of words, we'll end up with one
                    // block at the end with "missing" bytes; since these are equivalent to 0, we
                    // can simply ignore the fact they're missing.
                    continue;
                }
                let b = slice[off];
                #[cfg(not(reverse_bits))]
                {
                    if b != 0 {
                        {
                            let mut rb: u8 = 0; // the byte b with its bits in reverse order
                            for k in 0..8 {
                                rb |= ((b >> k) & 1) << (8 - k - 1);
                            }
                            w |= (rb as usize) << (j * 8);
                        }
                    }
                }
                #[cfg(reverse_bits)]
                {
                    w |= (b.reverse_bits() as usize) << (j * 8);
                }
            }
            v.vec.push(w);
        }
        v.len = new_len;
        v
    }
/// Create a Vob from a `u8` slice. The most significant bit of each byte comes first in the
/// resulting Vob.
///
/// # Examples
///
/// ```
/// use vob::{Vob, vob};
/// let v = Vob::from_bytes(&[0b10100000, 0b00010010]);
/// assert_eq!(v, vob![true, false, true, false, false, false, false, false,
///                    false, false, false, true, false, false, true, false]);
/// ```
Create a Vob from a `u8` slice. The most significant bit of each byte comes first in the
resulting Vob.
Create a Vob from a ` u8 ` slice . The most significant bit of each byte comes first in the resulting Vob .
pub fn from_bytes(slice: &[u8]) -> Vob<usize> {
        let new_len = slice.len().checked_mul(8).expect("Overflow detected");
        let mut v = Vob::with_capacity(new_len);
        for i in 0..blocks_required::<usize>(new_len) {
            let mut w = usize::zero();
            for j in 0..bytes_per_block::<usize>() {
                let off = i * bytes_per_block::<usize>() + j;
                if off >= slice.len() {
                    // If slice doesn't contain a whole number of words, we'll end up with one
                    // block at the end with "missing" bytes; since these are equivalent to 0, we
                    // can simply ignore the fact they're missing.
                    continue;
                }
                let b = slice[off];
                #[cfg(not(reverse_bits))]
                {
                    if b != 0 {
                        {
                            let mut rb: u8 = 0; // the byte b with its bits in reverse order
                            for k in 0..8 {
                                rb |= ((b >> k) & 1) << (8 - k - 1);
                            }
                            w |= (rb as usize) << (j * 8);
                        }
                    }
                }
                #[cfg(reverse_bits)]
                {
                    w |= (b.reverse_bits() as usize) << (j * 8);
                }
            }
            v.vec.push(w);
        }
        v.len = new_len;
        v
    }
pub fn from_bytes ( slice : & [ u8 ] ) -> Vob < usize > { let new_len = slice . len ( ) . checked_mul ( 8 ) . expect ( " " ) ; let mut v = Vob :: with_capacity ( new_len ) ; for i in 0 .. blocks_required :: < usize > ( new_len ) { let mut w = usize :: zero ( ) ; for j in 0 .. bytes_per_block :: < usize > ( ) { let off = i * bytes_per_block :: < usize > ( ) + j ; if off >= slice . len ( ) { // If slice doesn't contain a whole number of words, we'll end up with one // block at the end with "missing" bytes; since these are equivalent to 0, we // can simply ignore the fact they're missing. continue ; } let b = slice [ off ] ; # [ cfg ( not ( reverse_bits ) ) ] { if b != 0 { { let mut rb : u8 = 0 ; // the byte b with its bits in reverse order for k in 0 .. 8 { rb |= ( ( b >> k ) & 1 ) << ( 8 - k - 1 ) ; } w |= ( rb as usize ) << ( j * 8 ) ; } } } # [ cfg ( reverse_bits ) ] { w |= ( b . reverse_bits ( ) as usize ) << ( j * 8 ) ; } } v . vec . push ( w ) ; } v . len = new_len ; v }
Create a Vob from a `u8` slice.
Create a Vob from a ` u8 ` slice .
slice
&[u8]
slice
&[u8]
examples
None