Macro nom::tag_bits[][src]

macro_rules! tag_bits {
    ($i:expr, $count:expr, $p: expr) => { ... };
}

Matches the given bit pattern.

Signature: tag_bits!(type, count, pattern) => ( (&[T], usize), U, usize, U) -> IResult<(&[T], usize), U>

The caller must specify the number of bits to consume. The matched value is included in the result on success.

 named!( take_a<u8>, bits!( tag_bits!(4usize, 0xA) ) );

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

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