Macro nom::tag_bits [] [src]

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

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. ```

#[macro_use] extern crate nom;

use nom::IResult::Done;

fn main() {

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

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

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

}