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
16 fn matcher(&self, data: &[u8]) -> (bool, usize) {
17 match self {
18 OperatorTokens::Equal => match_pattern(b"==", data),
19 OperatorTokens::NotEqual => match_pattern(b"!=", data),
20 }
21 }