pub trait ContainsToken<T> {
// Required method
fn contains_token(&self, token: T) -> bool;
}Expand description
Check if a token is in a set of possible tokens
While this can be implemented manually, you can also build up sets using:
b'c'and'c'b""|c| trueb'a'..=b'z','a'..='z'(etc for each range type)(set1, set2, ...)
§Example
For example, you could implement hex_digit0 as:
fn hex_digit1<'s>(input: &mut &'s str) -> ModalResult<&'s str, ContextError> {
take_while(1.., ('a'..='f', 'A'..='F', '0'..='9')).parse_next(input)
}
assert_eq!(hex_digit1.parse_peek("21cZ"), Ok(("Z", "21c")));
assert!(hex_digit1.parse_peek("H2").is_err());
assert!(hex_digit1.parse_peek("").is_err());Required Methods§
Sourcefn contains_token(&self, token: T) -> bool
fn contains_token(&self, token: T) -> bool
Returns true if self contains the token