pub enum TokenKind {
Show 31 variants
Eq,
Lt,
Le,
EqEq,
Ne,
Ge,
Gt,
AndAnd,
OrOr,
Not,
Tilde,
Walrus,
PlusPlus,
MinusMinus,
StarStar,
BinOp(BinOpToken),
BinOpEq(BinOpToken),
At,
Dot,
Comma,
Semi,
Colon,
Arrow,
FatArrow,
Question,
OpenDelim(Delimiter),
CloseDelim(Delimiter),
Literal(TokenLitKind, Symbol),
Ident(Symbol),
Comment(bool, CommentKind, Symbol),
Eof,
}Expand description
A kind of token.
Variants§
Eq
=
Lt
<
Le
<=
EqEq
==
Ne
!=
Ge
>=
Gt
>
AndAnd
&&
OrOr
||
Not
!
Tilde
~
Walrus
:=
PlusPlus
++
MinusMinus
--
StarStar
**
BinOp(BinOpToken)
A binary operator token.
BinOpEq(BinOpToken)
A binary operator token, followed by an equals sign (=).
At
@
Dot
.
Comma
,
Semi
;
Colon
:
Arrow
->
FatArrow
=>
Question
?
OpenDelim(Delimiter)
An opening delimiter (e.g., {).
CloseDelim(Delimiter)
A closing delimiter (e.g., }).
Literal(TokenLitKind, Symbol)
A literal token.
Note that this does not include boolean literals.
Symbol is the literal’s parsed data. In string literals, this is the unescaped value, and
excludes its quotes (", ') and prefix (hex, unicode).
Ident(Symbol)
Identifier token.
Comment(bool, CommentKind, Symbol)
A comment or doc-comment token.
Symbol is the comment’s data excluding its “quotes” (//, /**)
similarly to symbols in string literal tokens.
Eof
End of file marker.
Implementations§
Source§impl TokenKind
impl TokenKind
Sourcepub fn lit(kind: TokenLitKind, symbol: Symbol) -> TokenKind
pub fn lit(kind: TokenLitKind, symbol: Symbol) -> TokenKind
Creates a new literal token kind.
Sourcepub fn description(&self) -> Cow<'_, str>
pub fn description(&self) -> Cow<'_, str>
Returns the description of the token kind.
Sourcepub fn as_unop(&self, is_postfix: bool) -> Option<UnOpKind>
pub fn as_unop(&self, is_postfix: bool) -> Option<UnOpKind>
Returns the token kind as a unary operator, if any.
Sourcepub fn as_binop(&self) -> Option<BinOpKind>
pub fn as_binop(&self) -> Option<BinOpKind>
Returns the token kind as a binary operator, if any.
Sourcepub fn as_binop_eq(&self) -> Option<BinOpKind>
pub fn as_binop_eq(&self) -> Option<BinOpKind>
Returns the token kind as a binary operator, if any.
Sourcepub const fn is_comment(&self) -> bool
pub const fn is_comment(&self) -> bool
Returns true if the token kind is a normal comment (not a doc-comment).
Sourcepub const fn is_comment_or_doc(&self) -> bool
pub const fn is_comment_or_doc(&self) -> bool
Returns true if the token kind is a comment or doc-comment.
Trait Implementations§
impl Copy for TokenKind
impl Eq for TokenKind
impl StructuralPartialEq for TokenKind
Auto Trait Implementations§
impl Freeze for TokenKind
impl RefUnwindSafe for TokenKind
impl Send for TokenKind
impl Sync for TokenKind
impl Unpin for TokenKind
impl UnwindSafe for TokenKind
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T, R> CollectAndApply<T, R> for T
impl<T, R> CollectAndApply<T, R> for T
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
fn equivalent(&self, key: &K) -> bool
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<Q> ToOwnedEquivalent<<Q as ToOwned>::Owned> for Q
impl<Q> ToOwnedEquivalent<<Q as ToOwned>::Owned> for Q
fn to_owned_equivalent(&self) -> <Q as ToOwned>::Owned
Source§impl<T> WithSubscriber for T
impl<T> WithSubscriber for T
Source§fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
Source§fn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Layout§
Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...) attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.
Size: 8 bytes
Size for each variant:
Eq: 0 bytesLt: 0 bytesLe: 0 bytesEqEq: 0 bytesNe: 0 bytesGe: 0 bytesGt: 0 bytesAndAnd: 0 bytesOrOr: 0 bytesNot: 0 bytesTilde: 0 bytesWalrus: 0 bytesPlusPlus: 0 bytesMinusMinus: 0 bytesStarStar: 0 bytesBinOp: 1 byteBinOpEq: 1 byteAt: 0 bytesDot: 0 bytesComma: 0 bytesSemi: 0 bytesColon: 0 bytesArrow: 0 bytesFatArrow: 0 bytesQuestion: 0 bytesOpenDelim: 1 byteCloseDelim: 1 byteLiteral: 7 bytesIdent: 7 bytesComment: 7 bytesEof: 0 bytes