Macro nom::take_bits [−][src]
macro_rules! take_bits { ($i:expr, $t:ty, $count:expr) => { ... }; }
Consumes the specified number of bits and returns them as the specified type.
Signature:
take_bits!(type, count) => ( (&[T], usize), U, usize) -> IResult<(&[T], usize), U>
named!( take_pair<(u8, u8)>, bits!( pair!( take_bits!(u8, 4), take_bits!(u8, 4) ) ) ); let input = vec![0xAB, 0xCD, 0xEF]; let sl = &input[..]; assert_eq!(take_pair( sl ), Ok((&sl[1..], (0xA, 0xB))) ); assert_eq!(take_pair( &sl[1..] ), Ok((&sl[2..], (0xC, 0xD))) );