pub trait FindToken<T> {
// Required method
fn find_token(&self, token: T) -> bool;
}
Expand description
Check if a token in in a set of possible tokens
This is generally implemented on patterns that a token may match and supports u8
and char
tokens along with the following patterns
b'c'
and'c'
b""
and""
|c| true
b'a'..=b'z'
,'a'..='z'
(etc for each range type)(pattern1, pattern2, ...)
For example, you could implement hex_digit0
as:
fn hex_digit1(input: &str) -> IResult<&str, &str> {
take_while1(('a'..='f', 'A'..='F', '0'..='9')).parse(input)
}
assert_eq!(hex_digit1("21cZ"), Ok(("Z", "21c")));
assert_eq!(hex_digit1("H2"), Err(Err::Error(Error::new("H2", ErrorKind::TakeWhile1))));
assert_eq!(hex_digit1(""), Err(Err::Error(Error::new("", ErrorKind::TakeWhile1))));
Required Methods§
sourcefn find_token(&self, token: T) -> bool
fn find_token(&self, token: T) -> bool
Returns true if self contains the token