[][src]Macro nom::bits

macro_rules! bits {
    ($i:expr, $submac:ident!( $($args:tt)* )) => { ... };
    ($i:expr, $f:expr) => { ... };
}

Transforms its byte slice input into a bit stream for the underlying parser. This allows the given bit stream parser to work on a byte slice input.

Signature: bits!( parser ) => ( &[u8], (&[u8], usize) -> IResult<(&[u8], usize), T> ) -> IResult<&[u8], T>

 named!( take_4_bits<u8>, bits!( take_bits!( u8, 4 ) ) );

 let input = vec![0xAB, 0xCD, 0xEF, 0x12];
 let sl    = &input[..];

 assert_eq!(take_4_bits( sl ), Ok( (&sl[1..], 0xA) ));