Skip to main content

TokenKind

Enum TokenKind 

Source
#[repr(u8)]
pub enum TokenKind {
Show 84 variants Whitespace = 0, LineComment = 1, BlockComment = 2, Shebang = 3, Ident = 4, RawIdent = 5, Lifetime = 6, Int = 7, Float = 8, Char = 9, Byte = 10, Str = 11, RawStr = 12, ByteStr = 13, RawByteStr = 14, CStr = 15, RawCStr = 16, As = 17, Async = 18, Await = 19, Break = 20, Const = 21, Continue = 22, Crate = 23, Dyn = 24, Else = 25, Enum = 26, Extern = 27, False = 28, Fn = 29, For = 30, If = 31, Impl = 32, In = 33, Let = 34, Loop = 35, Match = 36, Mod = 37, Move = 38, Mut = 39, Pub = 40, Ref = 41, Return = 42, SelfKw = 43, SelfType = 44, Static = 45, Struct = 46, Super = 47, Trait = 48, True = 49, Type = 50, Unsafe = 51, Use = 52, Where = 53, While = 54, Underscore = 55, LParen = 56, RParen = 57, LBrace = 58, RBrace = 59, LBracket = 60, RBracket = 61, Bang = 62, Hash = 63, Dollar = 64, Percent = 65, Amp = 66, Star = 67, Plus = 68, Comma = 69, Minus = 70, Dot = 71, Slash = 72, Colon = 73, Semi = 74, Lt = 75, Eq = 76, Gt = 77, Question = 78, At = 79, Caret = 80, Pipe = 81, Tilde = 82, Unknown = 83,
}
Expand description

Lexical kind of a Rust source token (edition-independent, context-free).

Variants§

§

Whitespace = 0

§

LineComment = 1

§

BlockComment = 2

§

Shebang = 3

§

Ident = 4

§

RawIdent = 5

§

Lifetime = 6

§

Int = 7

§

Float = 8

§

Char = 9

§

Byte = 10

§

Str = 11

§

RawStr = 12

§

ByteStr = 13

§

RawByteStr = 14

§

CStr = 15

§

RawCStr = 16

§

As = 17

§

Async = 18

§

Await = 19

§

Break = 20

§

Const = 21

§

Continue = 22

§

Crate = 23

§

Dyn = 24

§

Else = 25

§

Enum = 26

§

Extern = 27

§

False = 28

§

Fn = 29

§

For = 30

§

If = 31

§

Impl = 32

§

In = 33

§

Let = 34

§

Loop = 35

§

Match = 36

§

Mod = 37

§

Move = 38

§

Mut = 39

§

Pub = 40

§

Ref = 41

§

Return = 42

§

SelfKw = 43

§

SelfType = 44

§

Static = 45

§

Struct = 46

§

Super = 47

§

Trait = 48

§

True = 49

§

Type = 50

§

Unsafe = 51

§

Use = 52

§

Where = 53

§

While = 54

§

Underscore = 55

§

LParen = 56

§

RParen = 57

§

LBrace = 58

§

RBrace = 59

§

LBracket = 60

§

RBracket = 61

§

Bang = 62

§

Hash = 63

§

Dollar = 64

§

Percent = 65

§

Amp = 66

§

Star = 67

§

Plus = 68

§

Comma = 69

§

Minus = 70

§

Dot = 71

§

Slash = 72

§

Colon = 73

§

Semi = 74

§

Lt = 75

§

Eq = 76

§

Gt = 77

§

Question = 78

§

At = 79

§

Caret = 80

§

Pipe = 81

§

Tilde = 82

§

Unknown = 83

Implementations§

Source§

impl TokenKind

Source

pub const fn is_trivia(self) -> bool

Returns true for whitespace, comments (including doc comments), and file shebangs.

Source

pub const fn is_punct(self) -> bool

Returns true for non-delimiter atomic punctuation characters eligible for JOINT_NEXT.

Source

pub const fn is_delimiter(self) -> bool

Returns true for (, ), {, }, [, ].

Source

pub const fn is_keyword(self) -> bool

Returns true for strict keywords (excluding Self::Underscore).

Source

pub const fn is_literal(self) -> bool

Returns true for numeric, character, byte, string, and C-string literals.

Source

pub const fn punct_byte(self) -> Option<u8>

Maps an atomic punctuation TokenKind back to its ASCII byte, enabling fast multi-character operator checks (at_op("::"), eat_op("->"), at_op(">>")) in the parser.

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 Copy for TokenKind

Source§

impl Debug for TokenKind

Source§

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

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

impl Eq for TokenKind

Source§

impl Hash for TokenKind

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. 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, 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.