pub fn append_bits(&mut self, count: usize, to_set: &[u8]) {
        let new_len = self.len + count;
        let new_buf_len = (new_len + 7) >> 3;
        self.buffer.reserve(new_buf_len - self.buffer.len());

        let whole_bytes = count >> 3;
        let overrun = count & 7;

        let skew = self.len & 7;
        if skew == 0 {
            self.buffer.extend_from_slice(&to_set[..whole_bytes]);
            if overrun > 0 {
                let masked = to_set[whole_bytes] & ((1 << overrun) - 1);
                self.buffer.push(masked)
            }

            self.len = new_len;
            debug_assert_eq!(self.buffer.len(), new_buf_len);
            return;
        }

        for to_set_byte in &to_set[..whole_bytes] {
            let low = *to_set_byte << skew;
            let high = *to_set_byte >> (8 - skew);

            *self.buffer.last_mut().unwrap() |= low;
            self.buffer.push(high);
        }

        if overrun > 0 {
            let masked = to_set[whole_bytes] & ((1 << overrun) - 1);
            let low = masked << skew;
            *self.buffer.last_mut().unwrap() |= low;

            if overrun > 8 - skew {
                let high = masked >> (8 - skew);
                self.buffer.push(high)
            }
        }

        self.len = new_len;
        debug_assert_eq!(self.buffer.len(), new_buf_len);
    }
/// Appends `count` boolean values from the slice of packed bits
Appends `count` boolean values from the slice of packed bits
Appends ` count ` boolean values from the slice of packed bits
pub fn append_bits(&mut self, count: usize, to_set: &[u8]) {
        let new_len = self.len + count;
        let new_buf_len = (new_len + 7) >> 3;
        self.buffer.reserve(new_buf_len - self.buffer.len());
        let whole_bytes = count >> 3;
        let overrun = count & 7;
        let skew = self.len & 7;
        if skew == 0 {
            self.buffer.extend_from_slice(&to_set[..whole_bytes]);
            if overrun > 0 {
                let masked = to_set[whole_bytes] & ((1 << overrun) - 1);
                self.buffer.push(masked)
            }
            self.len = new_len;
            debug_assert_eq!(self.buffer.len(), new_buf_len);
            return;
        }
        for to_set_byte in &to_set[..whole_bytes] {
            let low = *to_set_byte << skew;
            let high = *to_set_byte >> (8 - skew);
            *self.buffer.last_mut().unwrap() |= low;
            self.buffer.push(high);
        }
        if overrun > 0 {
            let masked = to_set[whole_bytes] & ((1 << overrun) - 1);
            let low = masked << skew;
            *self.buffer.last_mut().unwrap() |= low;
            if overrun > 8 - skew {
                let high = masked >> (8 - skew);
                self.buffer.push(high)
            }
        }
        self.len = new_len;
        debug_assert_eq!(self.buffer.len(), new_buf_len);
    }
pub fn append_bits ( & mut self , count : usize , to_set : & [ u8 ] ) { let new_len = self . len + count ; let new_buf_len = ( new_len + 7 ) >> 3 ; self . buffer . reserve ( new_buf_len - self . buffer . len ( ) ) ; let whole_bytes = count >> 3 ; let overrun = count & 7 ; let skew = self . len & 7 ; if skew == 0 { self . buffer . extend_from_slice ( & to_set [ .. whole_bytes ] ) ; if overrun > 0 { let masked = to_set [ whole_bytes ] & ( ( 1 << overrun ) - 1 ) ; self . buffer . push ( masked ) } self . len = new_len ; debug_assert_eq ! ( self buffer len ( ) new_buf_len ) ; return ; } for to_set_byte in & to_set [ .. whole_bytes ] { let low = * to_set_byte << skew ; let high = * to_set_byte >> ( 8 - skew ) ; * self . buffer . last_mut ( ) . unwrap ( ) |= low ; self . buffer . push ( high ) ; } if overrun > 0 { let masked = to_set [ whole_bytes ] & ( ( 1 << overrun ) - 1 ) ; let low = masked << skew ; * self . buffer . last_mut ( ) . unwrap ( ) |= low ; if overrun > 8 - skew { let high = masked >> ( 8 - skew ) ; self . buffer . push ( high ) } } self . len = new_len ; debug_assert_eq ! ( self buffer len ( ) new_buf_len ) ; }
Appends `count` boolean values from the slice of packed bits
Appends ` count ` boolean values from the slice of packed bits
&mut self
count
usize
to_set
&[u8]
&mut self
count
usize
to_set
&[u8]