pub struct Token<'a> {
pub kind: TokenKind,
pub text: &'a str,
pub span: Span,
/* private fields */
}Expand description
A lexed token: its kind, source text, and byte-offset span.
Fields§
§kind: TokenKindThe token kind.
text: &'a strThe raw source text of the token.
span: SpanThe byte-offset span of the token in the source input.
Implementations§
Source§impl<'a> Token<'a>
impl<'a> Token<'a>
Sourcepub fn new(kind: TokenKind, text: &'a str, span: Span) -> Self
pub fn new(kind: TokenKind, text: &'a str, span: Span) -> Self
Creates a token from a kind, source text, and span.
Sourcepub fn is_keyword_or_identifier(&self) -> bool
pub fn is_keyword_or_identifier(&self) -> bool
Returns true when this token can stand in for a keyword or identifier.
FLOAT / INTEGER field-type keywords share kinds with numeric
literals; they count as identifiers only when the source text starts
with a letter.
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> UnsafeUnpin 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