pub struct Token<'a> {
pub lexeme: &'a str,
pub line: u32,
pub kind: TokenType,
}Expand description
Represents a single token in the source code
Fields§
§lexeme: &'a strThe actual text of the token
line: u32The line number where the token appears
kind: TokenTypeThe type of the token
Implementations§
Source§impl<'a> Token<'a>
impl<'a> Token<'a>
Sourcepub fn new(kind: TokenType, origin: &'a str, line: u32) -> Self
pub fn new(kind: TokenType, origin: &'a str, line: u32) -> Self
Creates a new token with the given type, text, and line number
pub fn is_function_def_keyword(&self) -> bool
pub fn is_error_type(&self) -> bool
pub fn is_literal_token(&self) -> bool
pub fn is_synchronize_keyword(&self) -> bool
Sourcepub fn is_expr_start(&self) -> bool
pub fn is_expr_start(&self) -> bool
Check if the token could start as an expression.
Trait Implementations§
impl<'a> Copy for Token<'a>
impl<'a> Eq for Token<'a>
impl<'a> StructuralPartialEq for Token<'a>
Auto Trait Implementations§
impl<'a> Freeze for Token<'a>
impl<'a> RefUnwindSafe for Token<'a>
impl<'a> Send for Token<'a>
impl<'a> Sync for Token<'a>
impl<'a> Unpin for Token<'a>
impl<'a> UnwindSafe for Token<'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