pub struct Token<'src> {
pub kind: TokenKind,
pub text: Cow<'src, str>,
pub span: Span,
}Expand description
A token produced by the lexer.
Token text is borrowed from the source string (Cow::Borrowed) in the
common case, avoiding per-token heap allocation. String literals with
escape sequences are the only tokens that own their text on the heap.
Fields§
§kind: TokenKindToken classification.
text: Cow<'src, str>Source text of the token — borrowed from input in the common case.
span: SpanSource location.
Implementations§
Trait Implementations§
impl<'src> StructuralPartialEq for Token<'src>
Auto Trait Implementations§
impl<'src> Freeze for Token<'src>
impl<'src> RefUnwindSafe for Token<'src>
impl<'src> Send for Token<'src>
impl<'src> Sync for Token<'src>
impl<'src> Unpin for Token<'src>
impl<'src> UnwindSafe for Token<'src>
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