Function pattern
fn pattern<Input, Output, Count, Error: ParserError<(Input, usize)>>(pattern: Output, count: Count) -> impl Parser<(Input, usize), Output, Error>
where
Input: Stream<Token = u8> + StreamIsPartial + Clone,
Count: ToUsize,
Output: From<u8> + AddAssign + Shl<usize, Output = Output> + Shr<usize, Output = Output> + PartialEq
Parse taking count bits and comparing them to pattern
Effective Signature
Assuming you are parsing a (&[u8], usize) bit [Stream]:
# use *;;
# use ContextError;
#
Example
# use *;
# use Bytes;
# use ContextError;
use pattern;
type Stream<'i> = &'i Bytes;
/// Compare the lowest `count` bits of `input` against the lowest `count` bits of `pattern`.
/// Return Ok and the matching section of `input` if there's a match.
/// Return Err if there's no match.
// The lowest 4 bits of 0b00001111 match the lowest 4 bits of 0b11111111.
assert_eq!;
// The lowest bit of 0b00001111 matches the lowest bit of 0b11111111 (both are 1).
assert_eq!;
// The lowest 2 bits of 0b11111111 and 0b00000001 are different.
assert!;
// The lowest 8 bits of 0b11111111 and 0b11111110 are different.
assert!;