Function match_pattern
Source pub fn match_pattern(pattern: &[u8], data: &[u8]) -> (bool, usize)
Expand description
Attempt to match a byte slice against a byte slice.
§Arguments
pattern - The byte slice to match against.
data - The byte slice to match against.
§Returns
A tuple containing a boolean indicating whether the match succeeded and
the number of bytes consumed if the match succeeded.
93 fn matcher(&self, data: &[u8]) -> (bool, usize) {
94 match self {
95 BinaryOperator::Add => match_pattern(b"+", data),
96 BinaryOperator::Mul => match_pattern(b"*", data),
97 }
98 }
More examples
Hide additional examples
15 fn matcher(&self, data: &[u8]) -> (bool, usize) {
16 match self {
17 OperatorTokens::Equal => match_pattern(b"==", data),
18 OperatorTokens::NotEqual => match_pattern(b"!=", data),
19 }
20 }