pub fn bitmask_n<const N: usize, U: UnsignedInteger>(
bytes: &'static [u8; 2],
) -> BitmaskExactParser<N, U>Expand description
Leaf parser for bitmask strings exactly N long.
ยงExamples
let parser = parser::bitmask_n::<10, u16>(b".#");
assert_eq!(
parser.parse(b"#.###....# abc"),
Ok((0b10_0001_1101, &b" abc"[..]))
);
assert_eq!(
parser.parse(b"#.###....##"),
Ok((0b10_0001_1101, &b"#"[..]))
);
assert!(parser.parse(b"#.###....").is_err());
assert!(parser.parse(b"#.###x...#").is_err());