pub trait TokenStream: Tokenizer {
// Required method
fn unread(&mut self, token: Self::Token);
// Provided methods
fn parse<T>(&mut self) -> Result<T>
where T: Parse<Self>,
Self: Sized { ... }
fn peek(&mut self) -> Result<Self::Token>
where Self::Token: Clone { ... }
fn peek2(&mut self) -> Result<(Self::Token, Self::Token)>
where Self::Token: Clone { ... }
fn peek_n(&mut self, n: usize) -> Result<Vec<Self::Token>>
where Self::Token: Clone { ... }
fn skip_until<F>(&mut self, f: F) -> Result<()>
where F: FnMut(&Self::Token) -> bool { ... }
fn collect_until<F>(&mut self, f: F) -> Result<Vec<Self::Token>>
where F: FnMut(&Self::Token) -> bool { ... }
fn expect<T>(&mut self, token: T) -> Result<Self::Token>
where Self::Token: PartialEq<T> + Spanned + Display,
T: Display { ... }
fn lookahead(&mut self) -> Lookahead<'_, Self, Self::Token>
where Self: Sized { ... }
}Expand description
Trait for token streams.
Required Methods§
Provided Methods§
Sourcefn peek(&mut self) -> Result<Self::Token>
fn peek(&mut self) -> Result<Self::Token>
Peeks the next token from the token stream.
Does not advance the position of the token stream.
Sourcefn peek2(&mut self) -> Result<(Self::Token, Self::Token)>
fn peek2(&mut self) -> Result<(Self::Token, Self::Token)>
Peeks the next 2 tokens from the token stream.
Does not advance the position of the token stream.
Sourcefn peek_n(&mut self, n: usize) -> Result<Vec<Self::Token>>
fn peek_n(&mut self, n: usize) -> Result<Vec<Self::Token>>
Peeks the next N tokens from the token stream.
Does not advance the position of the token stream.
Sourcefn skip_until<F>(&mut self, f: F) -> Result<()>
fn skip_until<F>(&mut self, f: F) -> Result<()>
Skips tokens untils a token specified by the predicate is encountered.
Sourcefn collect_until<F>(&mut self, f: F) -> Result<Vec<Self::Token>>
fn collect_until<F>(&mut self, f: F) -> Result<Vec<Self::Token>>
Collects tokens into a Vec until a token specified by the predicate
is encountered.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.