pub struct TokenStream<'a> { /* private fields */ }Implementations§
Source§impl<'a> TokenStream<'a>
impl<'a> TokenStream<'a>
pub fn new(input: &'a str) -> Self
Sourcepub fn current_position(&self) -> (usize, usize)
pub fn current_position(&self) -> (usize, usize)
Get the current line and column position
Sourcepub fn get_context_string(&self) -> String
pub fn get_context_string(&self) -> String
Get a string showing the context around the current position
Sourcepub fn position(&self) -> TokenStreamPosition<'a>
pub fn position(&self) -> TokenStreamPosition<'a>
Save the current position for later restoration
Sourcepub fn set_position(&mut self, pos: TokenStreamPosition<'a>)
pub fn set_position(&mut self, pos: TokenStreamPosition<'a>)
Restore a previously saved position
pub fn next(&mut self) -> Option<(Token, Span)>
pub fn peek(&mut self) -> Option<&(Token, Span)>
Sourcepub fn peek_ahead(&mut self, n: usize) -> Option<(Token, Span)>
pub fn peek_ahead(&mut self, n: usize) -> Option<(Token, Span)>
Look ahead n tokens in the stream
pub fn peek_nth(&mut self, n: usize) -> Option<(Token, Span)>
pub fn peek_nth_is_colon(&mut self, n: usize) -> bool
Sourcepub fn expect(&mut self, expected: &Token) -> Result<Span>
pub fn expect(&mut self, expected: &Token) -> Result<Span>
Expect a specific token and return its span
§Errors
Returns an error if the next token doesn’t match the expected token or if we reached EOF
pub fn advance(&mut self) -> Option<(Token, Span)>
Auto Trait Implementations§
impl<'a> Freeze for TokenStream<'a>
impl<'a> RefUnwindSafe for TokenStream<'a>
impl<'a> Send for TokenStream<'a>
impl<'a> Sync for TokenStream<'a>
impl<'a> Unpin for TokenStream<'a>
impl<'a> UnwindSafe for TokenStream<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more