devela::_dep::winnow::stream

Trait ContainsToken

pub trait ContainsToken<T> {
    // Required method
    fn contains_token(&self, token: T) -> bool;
}
Available on crate feature dep_winnow only.
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| true
  • b'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§

fn contains_token(&self, token: T) -> bool

Returns true if self contains the token

Implementations on Foreign Types§

§

impl ContainsToken<&char> for u8

§

fn contains_token(&self, token: &char) -> bool

§

impl ContainsToken<&u8> for u8

§

fn contains_token(&self, token: &u8) -> bool

§

impl ContainsToken<char> for u8

§

fn contains_token(&self, token: char) -> bool

§

impl ContainsToken<u8> for u8

§

fn contains_token(&self, token: u8) -> bool

§

impl<C> ContainsToken<C> for &[char]
where C: AsChar,

§

fn contains_token(&self, token: C) -> bool

§

impl<C> ContainsToken<C> for &[u8]
where C: AsChar,

§

fn contains_token(&self, token: C) -> bool

§

impl<C> ContainsToken<C> for char
where C: AsChar,

§

fn contains_token(&self, token: C) -> bool

§

impl<T> ContainsToken<T> for ()

§

fn contains_token(&self, _token: T) -> bool

§

impl<T, F1> ContainsToken<T> for (F1,)
where T: Clone, F1: ContainsToken<T>,

§

fn contains_token(&self, token: T) -> bool

§

impl<T, F1, F2> ContainsToken<T> for (F1, F2)
where T: Clone, F1: ContainsToken<T>, F2: ContainsToken<T>,

§

fn contains_token(&self, token: T) -> bool

§

impl<T, F1, F2, F3> ContainsToken<T> for (F1, F2, F3)
where T: Clone, F1: ContainsToken<T>, F2: ContainsToken<T>, F3: ContainsToken<T>,

§

fn contains_token(&self, token: T) -> bool

§

impl<T, F1, F2, F3, F4> ContainsToken<T> for (F1, F2, F3, F4)
where T: Clone, F1: ContainsToken<T>, F2: ContainsToken<T>, F3: ContainsToken<T>, F4: ContainsToken<T>,

§

fn contains_token(&self, token: T) -> bool

§

impl<T, F1, F2, F3, F4, F5> ContainsToken<T> for (F1, F2, F3, F4, F5)
where T: Clone, F1: ContainsToken<T>, F2: ContainsToken<T>, F3: ContainsToken<T>, F4: ContainsToken<T>, F5: ContainsToken<T>,

§

fn contains_token(&self, token: T) -> bool

§

impl<T, F1, F2, F3, F4, F5, F6> ContainsToken<T> for (F1, F2, F3, F4, F5, F6)
where T: Clone, F1: ContainsToken<T>, F2: ContainsToken<T>, F3: ContainsToken<T>, F4: ContainsToken<T>, F5: ContainsToken<T>, F6: ContainsToken<T>,

§

fn contains_token(&self, token: T) -> bool

§

impl<T, F1, F2, F3, F4, F5, F6, F7> ContainsToken<T> for (F1, F2, F3, F4, F5, F6, F7)
where T: Clone, F1: ContainsToken<T>, F2: ContainsToken<T>, F3: ContainsToken<T>, F4: ContainsToken<T>, F5: ContainsToken<T>, F6: ContainsToken<T>, F7: ContainsToken<T>,

§

fn contains_token(&self, token: T) -> bool

§

impl<T, F1, F2, F3, F4, F5, F6, F7, F8> ContainsToken<T> for (F1, F2, F3, F4, F5, F6, F7, F8)
where T: Clone, F1: ContainsToken<T>, F2: ContainsToken<T>, F3: ContainsToken<T>, F4: ContainsToken<T>, F5: ContainsToken<T>, F6: ContainsToken<T>, F7: ContainsToken<T>, F8: ContainsToken<T>,

§

fn contains_token(&self, token: T) -> bool

§

impl<T, F1, F2, F3, F4, F5, F6, F7, F8, F9> ContainsToken<T> for (F1, F2, F3, F4, F5, F6, F7, F8, F9)
where T: Clone, F1: ContainsToken<T>, F2: ContainsToken<T>, F3: ContainsToken<T>, F4: ContainsToken<T>, F5: ContainsToken<T>, F6: ContainsToken<T>, F7: ContainsToken<T>, F8: ContainsToken<T>, F9: ContainsToken<T>,

§

fn contains_token(&self, token: T) -> bool

§

impl<T, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10> ContainsToken<T> for (F1, F2, F3, F4, F5, F6, F7, F8, F9, F10)
where T: Clone, F1: ContainsToken<T>, F2: ContainsToken<T>, F3: ContainsToken<T>, F4: ContainsToken<T>, F5: ContainsToken<T>, F6: ContainsToken<T>, F7: ContainsToken<T>, F8: ContainsToken<T>, F9: ContainsToken<T>, F10: ContainsToken<T>,

§

fn contains_token(&self, token: T) -> bool

§

impl<T, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11> ContainsToken<T> for (F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11)
where T: Clone, F1: ContainsToken<T>, F2: ContainsToken<T>, F3: ContainsToken<T>, F4: ContainsToken<T>, F5: ContainsToken<T>, F6: ContainsToken<T>, F7: ContainsToken<T>, F8: ContainsToken<T>, F9: ContainsToken<T>, F10: ContainsToken<T>, F11: ContainsToken<T>,

§

fn contains_token(&self, token: T) -> bool

§

impl<T, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12> ContainsToken<T> for (F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12)
where T: Clone, F1: ContainsToken<T>, F2: ContainsToken<T>, F3: ContainsToken<T>, F4: ContainsToken<T>, F5: ContainsToken<T>, F6: ContainsToken<T>, F7: ContainsToken<T>, F8: ContainsToken<T>, F9: ContainsToken<T>, F10: ContainsToken<T>, F11: ContainsToken<T>, F12: ContainsToken<T>,

§

fn contains_token(&self, token: T) -> bool

§

impl<T, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, F13> ContainsToken<T> for (F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, F13)
where T: Clone, F1: ContainsToken<T>, F2: ContainsToken<T>, F3: ContainsToken<T>, F4: ContainsToken<T>, F5: ContainsToken<T>, F6: ContainsToken<T>, F7: ContainsToken<T>, F8: ContainsToken<T>, F9: ContainsToken<T>, F10: ContainsToken<T>, F11: ContainsToken<T>, F12: ContainsToken<T>, F13: ContainsToken<T>,

§

fn contains_token(&self, token: T) -> bool

§

impl<T, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, F13, F14> ContainsToken<T> for (F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, F13, F14)
where T: Clone, F1: ContainsToken<T>, F2: ContainsToken<T>, F3: ContainsToken<T>, F4: ContainsToken<T>, F5: ContainsToken<T>, F6: ContainsToken<T>, F7: ContainsToken<T>, F8: ContainsToken<T>, F9: ContainsToken<T>, F10: ContainsToken<T>, F11: ContainsToken<T>, F12: ContainsToken<T>, F13: ContainsToken<T>, F14: ContainsToken<T>,

§

fn contains_token(&self, token: T) -> bool

§

impl<T, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, F13, F14, F15> ContainsToken<T> for (F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, F13, F14, F15)
where T: Clone, F1: ContainsToken<T>, F2: ContainsToken<T>, F3: ContainsToken<T>, F4: ContainsToken<T>, F5: ContainsToken<T>, F6: ContainsToken<T>, F7: ContainsToken<T>, F8: ContainsToken<T>, F9: ContainsToken<T>, F10: ContainsToken<T>, F11: ContainsToken<T>, F12: ContainsToken<T>, F13: ContainsToken<T>, F14: ContainsToken<T>, F15: ContainsToken<T>,

§

fn contains_token(&self, token: T) -> bool

§

impl<T, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, F13, F14, F15, F16> ContainsToken<T> for (F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, F13, F14, F15, F16)
where T: Clone, F1: ContainsToken<T>, F2: ContainsToken<T>, F3: ContainsToken<T>, F4: ContainsToken<T>, F5: ContainsToken<T>, F6: ContainsToken<T>, F7: ContainsToken<T>, F8: ContainsToken<T>, F9: ContainsToken<T>, F10: ContainsToken<T>, F11: ContainsToken<T>, F12: ContainsToken<T>, F13: ContainsToken<T>, F14: ContainsToken<T>, F15: ContainsToken<T>, F16: ContainsToken<T>,

§

fn contains_token(&self, token: T) -> bool

§

impl<T, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, F13, F14, F15, F16, F17> ContainsToken<T> for (F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, F13, F14, F15, F16, F17)
where T: Clone, F1: ContainsToken<T>, F2: ContainsToken<T>, F3: ContainsToken<T>, F4: ContainsToken<T>, F5: ContainsToken<T>, F6: ContainsToken<T>, F7: ContainsToken<T>, F8: ContainsToken<T>, F9: ContainsToken<T>, F10: ContainsToken<T>, F11: ContainsToken<T>, F12: ContainsToken<T>, F13: ContainsToken<T>, F14: ContainsToken<T>, F15: ContainsToken<T>, F16: ContainsToken<T>, F17: ContainsToken<T>,

§

fn contains_token(&self, token: T) -> bool

§

impl<T, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, F13, F14, F15, F16, F17, F18> ContainsToken<T> for (F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, F13, F14, F15, F16, F17, F18)
where T: Clone, F1: ContainsToken<T>, F2: ContainsToken<T>, F3: ContainsToken<T>, F4: ContainsToken<T>, F5: ContainsToken<T>, F6: ContainsToken<T>, F7: ContainsToken<T>, F8: ContainsToken<T>, F9: ContainsToken<T>, F10: ContainsToken<T>, F11: ContainsToken<T>, F12: ContainsToken<T>, F13: ContainsToken<T>, F14: ContainsToken<T>, F15: ContainsToken<T>, F16: ContainsToken<T>, F17: ContainsToken<T>, F18: ContainsToken<T>,

§

fn contains_token(&self, token: T) -> bool

§

impl<T, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, F13, F14, F15, F16, F17, F18, F19> ContainsToken<T> for (F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, F13, F14, F15, F16, F17, F18, F19)
where T: Clone, F1: ContainsToken<T>, F2: ContainsToken<T>, F3: ContainsToken<T>, F4: ContainsToken<T>, F5: ContainsToken<T>, F6: ContainsToken<T>, F7: ContainsToken<T>, F8: ContainsToken<T>, F9: ContainsToken<T>, F10: ContainsToken<T>, F11: ContainsToken<T>, F12: ContainsToken<T>, F13: ContainsToken<T>, F14: ContainsToken<T>, F15: ContainsToken<T>, F16: ContainsToken<T>, F17: ContainsToken<T>, F18: ContainsToken<T>, F19: ContainsToken<T>,

§

fn contains_token(&self, token: T) -> bool

§

impl<T, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, F13, F14, F15, F16, F17, F18, F19, F20> ContainsToken<T> for (F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, F13, F14, F15, F16, F17, F18, F19, F20)
where T: Clone, F1: ContainsToken<T>, F2: ContainsToken<T>, F3: ContainsToken<T>, F4: ContainsToken<T>, F5: ContainsToken<T>, F6: ContainsToken<T>, F7: ContainsToken<T>, F8: ContainsToken<T>, F9: ContainsToken<T>, F10: ContainsToken<T>, F11: ContainsToken<T>, F12: ContainsToken<T>, F13: ContainsToken<T>, F14: ContainsToken<T>, F15: ContainsToken<T>, F16: ContainsToken<T>, F17: ContainsToken<T>, F18: ContainsToken<T>, F19: ContainsToken<T>, F20: ContainsToken<T>,

§

fn contains_token(&self, token: T) -> bool

§

impl<T, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, F13, F14, F15, F16, F17, F18, F19, F20, F21> ContainsToken<T> for (F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, F13, F14, F15, F16, F17, F18, F19, F20, F21)
where T: Clone, F1: ContainsToken<T>, F2: ContainsToken<T>, F3: ContainsToken<T>, F4: ContainsToken<T>, F5: ContainsToken<T>, F6: ContainsToken<T>, F7: ContainsToken<T>, F8: ContainsToken<T>, F9: ContainsToken<T>, F10: ContainsToken<T>, F11: ContainsToken<T>, F12: ContainsToken<T>, F13: ContainsToken<T>, F14: ContainsToken<T>, F15: ContainsToken<T>, F16: ContainsToken<T>, F17: ContainsToken<T>, F18: ContainsToken<T>, F19: ContainsToken<T>, F20: ContainsToken<T>, F21: ContainsToken<T>,

§

fn contains_token(&self, token: T) -> bool

§

impl<const LEN: usize, C> ContainsToken<C> for &[char; LEN]
where C: AsChar,

§

fn contains_token(&self, token: C) -> bool

§

impl<const LEN: usize, C> ContainsToken<C> for &[u8; LEN]
where C: AsChar,

§

fn contains_token(&self, token: C) -> bool

§

impl<const LEN: usize, C> ContainsToken<C> for [char; LEN]
where C: AsChar,

§

fn contains_token(&self, token: C) -> bool

§

impl<const LEN: usize, C> ContainsToken<C> for [u8; LEN]
where C: AsChar,

§

fn contains_token(&self, token: C) -> bool

Implementors§

§

impl<C1> ContainsToken<C1> for RangeFull
where C1: AsChar,

§

impl<C1, C2> ContainsToken<C1> for Range<C2>
where C1: AsChar, C2: AsChar + Clone,

§

impl<C1, C2> ContainsToken<C1> for RangeFrom<C2>
where C1: AsChar, C2: AsChar + Clone,

§

impl<C1, C2> ContainsToken<C1> for RangeInclusive<C2>
where C1: AsChar, C2: AsChar + Clone,

§

impl<C1, C2> ContainsToken<C1> for RangeTo<C2>
where C1: AsChar, C2: AsChar + Clone,

§

impl<C1, C2> ContainsToken<C1> for RangeToInclusive<C2>
where C1: AsChar, C2: AsChar + Clone,

§

impl<C, F> ContainsToken<C> for F
where F: Fn(C) -> bool,