pub struct Token {
pub kind: TokenKind,
pub span: Span,
}Expand description
Represents a token in the lexer.
Tokens are the smallest units of a programming language. They represent individual elements such as keywords, identifiers, literals, and symbols. Tokens are used by the lexer to break down the source code into meaningful components that can be processed by the parser.
Tokens are useful because they provide a structured representation of the source code, allowing for easier analysis, interpretation, and transformation of the code. They serve as the foundation for building compilers, interpreters, and other language processing tools.
Fields§
§kind: TokenKind§span: SpanTrait Implementations§
source§impl Display for Token
impl Display for Token
Implements the Display trait for the Token struct.
This allows the Token struct to be formatted as a string.
source§impl PartialEq for Token
impl PartialEq for Token
impl StructuralPartialEq for Token
Auto Trait Implementations§
impl RefUnwindSafe for Token
impl Send for Token
impl Sync for Token
impl Unpin for Token
impl UnwindSafe for Token
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