Trait winnow::stream::ContainsToken
source · 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) -> PResult<&'s str, InputError<&'s str>> {
take_while(1.., ('a'..='f', 'A'..='F', '0'..='9')).parse_next(input)
}
assert_eq!(hex_digit1.parse_peek("21cZ"), Ok(("Z", "21c")));
assert_eq!(hex_digit1.parse_peek("H2"), Err(ErrMode::Backtrack(InputError::new("H2", ErrorKind::Slice))));
assert_eq!(hex_digit1.parse_peek(""), Err(ErrMode::Backtrack(InputError::new("", ErrorKind::Slice))));Required Methods§
sourcefn contains_token(&self, token: T) -> bool
fn contains_token(&self, token: T) -> bool
Returns true if self contains the token