pub struct TokenCursor<'a> { /* private fields */ }Expand description
A cursor for reading tokens with position tracking and backtracking.
Implementations§
Source§impl<'a> TokenCursor<'a>
impl<'a> TokenCursor<'a>
Sourcepub fn try_consume(&mut self, kind: &TokenKind) -> bool
pub fn try_consume(&mut self, kind: &TokenKind) -> bool
Consume if the current token kind matches.
Sourcepub fn expect_kind(&mut self, kind: &TokenKind) -> Result<&'a Token, String>
pub fn expect_kind(&mut self, kind: &TokenKind) -> Result<&'a Token, String>
Expect the current kind matches, else return an error string.
Sourcepub fn remaining_slice(&self) -> &'a [Token]
pub fn remaining_slice(&self) -> &'a [Token]
Get a slice of the remaining tokens.
Sourcepub fn collect_until<F: Fn(&Token) -> bool>(
&mut self,
pred: F,
) -> Vec<&'a Token>
pub fn collect_until<F: Fn(&Token) -> bool>( &mut self, pred: F, ) -> Vec<&'a Token>
Collect tokens until pred returns true.
Sourcepub fn skip_while<F: Fn(&Token) -> bool>(&mut self, pred: F)
pub fn skip_while<F: Fn(&Token) -> bool>(&mut self, pred: F)
Skip tokens as long as pred returns true.
Auto Trait Implementations§
impl<'a> Freeze for TokenCursor<'a>
impl<'a> RefUnwindSafe for TokenCursor<'a>
impl<'a> Send for TokenCursor<'a>
impl<'a> Sync for TokenCursor<'a>
impl<'a> Unpin for TokenCursor<'a>
impl<'a> UnsafeUnpin for TokenCursor<'a>
impl<'a> UnwindSafe for TokenCursor<'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