pub struct Input {
pub tokens: VecDeque<TokenTree>,
pub end: Span,
}Expand description
Fields§
§tokens: VecDeque<TokenTree>§end: SpanThis currently is usually a “one-token-past-the-end”-Span.
Top-level input should default to Span::call_site().
If Span::end is stabilised, then that will be a better option and should be used instead where applicable.
Implementations§
Source§impl Input
impl Input
Sourcepub fn peek<'a, const N: usize>(
&'a self,
f: impl FnOnce([&TokenTree; N], Iter<'a, TokenTree>) -> bool,
) -> bool
pub fn peek<'a, const N: usize>( &'a self, f: impl FnOnce([&TokenTree; N], Iter<'a, TokenTree>) -> bool, ) -> bool
Convenience method to match an array of &TokenTrees.
This is mostly for PeekFrom implementations.
Grammar consumers should call Token::peek_from instead.
Iff self is long enough, f is called with references to the frontmost tokens
and a vec_deque::Iter over the remaining tokens after them.
§Returns
false if self is too short, otherwise the return value of f.
Sourcepub fn pop_or_replace<'a, T, const N: usize>(
&'a mut self,
f: impl FnOnce([TokenTree; N], &mut Self) -> Result<T, [TokenTree; N]>,
) -> Result<T, impl 'a + IntoIterator<Item = Span>>
pub fn pop_or_replace<'a, T, const N: usize>( &'a mut self, f: impl FnOnce([TokenTree; N], &mut Self) -> Result<T, [TokenTree; N]>, ) -> Result<T, impl 'a + IntoIterator<Item = Span>>
Convenience method to match from an array of TokenTrees.
This is mostly for PopFrom implementations.
Grammar consumers should call Token::pop_from instead.
Iff self is long enough, f is called with the frontmost tokens
and an &mut Input pointing to self.
§Returns
If self is too short or f returns Err,
respective Spans to create an Error with.
Iff self is too short, self.end is included.