pub fn to_bytes(&self) -> Vec<u8> {
        fn bit(bitv: &Bitv, byte: uint, bit: uint) -> u8 {
            let offset = byte * 8 + bit;
            if offset >= bitv.nbits {
                0
            } else {
                (bitv[offset] as u8) << (7 - bit)
            }
        }

        let len = self.nbits/8 +
                  if self.nbits % 8 == 0 { 0 } else { 1 };
        (0..len).map(|i|
            bit(self, i, 0) |
            bit(self, i, 1) |
            bit(self, i, 2) |
            bit(self, i, 3) |
            bit(self, i, 4) |
            bit(self, i, 5) |
            bit(self, i, 6) |
            bit(self, i, 7)
        ).collect()
    }
/// Organises the bits into bytes, such that the first bit in the
/// `Bitv` becomes the high-order bit of the first byte. If the
/// size of the `Bitv` is not a multiple of eight then trailing bits
/// will be filled-in with `false`.
///
/// # Examples
///
/// ```
/// use std::collections::Bitv;
///
/// let mut bv = Bitv::from_elem(3, true);
/// bv.set(1, false);
///
/// assert_eq!(bv.to_bytes(), vec!(0b10100000));
///
/// let mut bv = Bitv::from_elem(9, false);
/// bv.set(2, true);
/// bv.set(8, true);
///
/// assert_eq!(bv.to_bytes(), vec!(0b00100000, 0b10000000));
/// ```
Organises the bits into bytes, such that the first bit in the
`Bitv` becomes the high-order bit of the first byte. If the
size of the `Bitv` is not a multiple of eight then trailing bits
will be filled-in with `false`.
Organises the bits into bytes such that the first bit in the ` Bitv ` becomes the high - order bit of the first byte . If the size of the ` Bitv ` is not a multiple of eight then trailing bits will be filled - in with ` false ` .
pub fn to_bytes(&self) -> Vec<u8> {
        fn bit(bitv: &Bitv, byte: uint, bit: uint) -> u8 {
            let offset = byte * 8 + bit;
            if offset >= bitv.nbits {
                0
            } else {
                (bitv[offset] as u8) << (7 - bit)
            }
        }
        let len = self.nbits/8 +
                  if self.nbits % 8 == 0 { 0 } else { 1 };
        (0..len).map(|i|
            bit(self, i, 0) |
            bit(self, i, 1) |
            bit(self, i, 2) |
            bit(self, i, 3) |
            bit(self, i, 4) |
            bit(self, i, 5) |
            bit(self, i, 6) |
            bit(self, i, 7)
        ).collect()
    }
pub fn to_bytes ( & self ) -> Vec < u8 > { fn bit ( bitv : & Bitv , byte : uint , bit : uint ) -> u8 { let offset = byte * 8 + bit ; if offset >= bitv . nbits { 0 } else { ( bitv [ offset ] as u8 ) << ( 7 - bit ) } } let len = self . nbits / 8 + if self . nbits % 8 == 0 { 0 } else { 1 } ; ( 0 .. len ) . map ( | i | bit ( self , i , 0 ) | bit ( self , i , 1 ) | bit ( self , i , 2 ) | bit ( self , i , 3 ) | bit ( self , i , 4 ) | bit ( self , i , 5 ) | bit ( self , i , 6 ) | bit ( self , i , 7 ) ) . collect ( ) }
Organises the bits into bytes, such that the first bit in the
`Bitv` becomes the high-order bit of the first byte.
Organises the bits into bytes such that the first bit in the ` Bitv ` becomes the high - order bit of the first byte .
&self
&self
examples
```
use std::collections::Bitv.

let mut bv = Bitv::from_elem(3, true);
bv.set(1, false).



let mut bv = Bitv::from_elem(9, false);
bv.set(2, true);
bv.set(8, true).


` ` ` use std :: collections :: Bitv . let mut bv = Bitv :: from_elem ( 3 true ) ; bv . set ( 1 false ) . let mut bv = Bitv :: from_elem ( 9 false ) ; bv . set ( 2 true ) ; bv . set ( 8 true ) .