Skip to main content

TokenKind

Enum TokenKind 

Source
pub enum TokenKind {
Show 85 variants Ident, Int(u64), Float(f64), Str(String), FStr(Vec<FPart>), DocOuter(String), DocInner(String), Newline, Module, Extern, Impl, Fn, Pub, Let, Var, Type, Struct, Enum, Interface, If, Else, Match, While, For, In, Return, Break, Continue, Loop, Mut, Own, SelfValue, SelfType, True, False, Async, Await, LParen, RParen, LBracket, RBracket, LBrace, RBrace, Comma, Dot, DotDot, DotDotEq, Colon, Question, Underscore, Eq, Arrow, FatArrow, Plus, Minus, Star, Slash, Percent, EqEq, NotEq, Lt, Le, Gt, Ge, AndAnd, OrOr, Bang, Amp, Pipe, Caret, Tilde, Shl, Shr, PlusEq, MinusEq, StarEq, SlashEq, PercentEq, AmpEq, PipeEq, CaretEq, ShlEq, ShrEq, Error, Eof,
}
Expand description

The kind of a token, with the value of literals.

Variants§

§

Ident

An identifier. Contextual keywords (imports, as, from, …) are identifiers too.

§

Int(u64)

An integer literal. The value is at most 2^63 (spec chapter 1, section 5.1).

§

Float(f64)

A float literal.

§

Str(String)

A string literal, with escapes already resolved. Raw (r"...") and multiline (""") strings are string literals too.

§

FStr(Vec<FPart>)

An interpolated string f"..." (spec chapter 1, section 5.3a), split into its parts.

§

DocOuter(String)

An outer doc comment (/// or /** */) with its text after the marker.

§

DocInner(String)

An inner doc comment (//! or /*! */) with its text after the marker.

§

Newline

One or more line ends (spec chapter 1, section 7).

§

Module

module

§

Extern

extern

§

Impl

impl

§

Fn

fn

§

Pub

pub

§

Let

let

§

Var

var

§

Type

type

§

Struct

struct

§

Enum

enum

§

Interface

interface

§

If

if

§

Else

else

§

Match

match

§

While

while

§

For

for

§

In

in

§

Return

return

§

Break

break

§

Continue

continue

§

Loop

loop

§

Mut

mut

§

Own

own

§

SelfValue

self

§

SelfType

Self

§

True

true

§

False

false

§

Async

async (reserved for the future)

§

Await

await (reserved for the future)

§

LParen

(

§

RParen

)

§

LBracket

[

§

RBracket

]

§

LBrace

{

§

RBrace

}

§

Comma

,

§

Dot

.

§

DotDot

..

§

DotDotEq

..=

§

Colon

:

§

Question

?

§

Underscore

_

§

Eq

=

§

Arrow

->

§

FatArrow

=>

§

Plus

+

§

Minus

-

§

Star

*

§

Slash

/

§

Percent

%

§

EqEq

==

§

NotEq

!=

§

Lt

<

§

Le

<=

§

Gt

>

§

Ge

>=

§

AndAnd

&&

§

OrOr

||

§

Bang

!

§

Amp

&

§

Pipe

|

§

Caret

^

§

Tilde

~

§

Shl

<<

§

Shr

>>

§

PlusEq

+=

§

MinusEq

-=

§

StarEq

*=

§

SlashEq

/=

§

PercentEq

%=

§

AmpEq

&=

§

PipeEq

|=

§

CaretEq

^=

§

ShlEq

<<=

§

ShrEq

>>=

§

Error

Text that could not be lexed. A diagnostic has been reported for it.

§

Eof

The end of the file. Always the last token.

Implementations§

Source§

impl TokenKind

Source

pub fn keyword(text: &str) -> Option<TokenKind>

The keyword for an identifier text, if it is a reserved word (spec chapter 1, section 4).

Source

pub fn spelling(&self) -> Option<&'static str>

The fixed spelling of keywords and punctuation, if the kind has one.

Trait Implementations§

Source§

impl Clone for TokenKind

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for TokenKind

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for TokenKind

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for TokenKind

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for TokenKind

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.