pub struct Token {
pub lexeme: String,
pub tok_type: TokType,
pub context: Option<TokenContext>,
}
Expand description
Represents a source token
Unlike the spans found in crate::tokenize::Tokens, these tokens are of an owned type containing an owned String of the lexeme from source.
The typical way to obtain a Token is from the source_to_tokens function. But tokens can be created without source documents, too.
Fields§
§lexeme: String
The contents of the token, exactly as it appears in source
tok_type: TokType
the type of the token
context: Option<TokenContext>
Contextual information about the Token’s position in the source document (if available) Because tokens can be created without a source doc, this field is an Option and may be None.
Trait Implementations§
impl StructuralPartialEq for Token
Auto Trait Implementations§
impl Freeze for Token
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