pub struct Token {
    pub kind: TokenKind,
    pub span: Span,
}

Fields

kind: TokenKindspan: Span

Implementations

Some token that will be thrown away later.

Recovers a Token from an Ident. This creates a raw identifier if necessary.

Return this token by value and leave a dummy token in its place.

For interpolated tokens, returns a span of the fragment to which the interpolated token refers. For all other tokens this is just a regular span. It is particularly important to use this for identifiers and lifetimes for which spans affect name resolution and edition checks. Note that keywords are also identifiers, so they should use this if they keep spans or perform edition checks.

Returns true if the token can appear at the start of an expression.

Returns true if the token can appear at the start of an pattern.

Shamelessly borrowed from can_begin_expr, only used for diagnostics right now.

Returns true if the token can appear at the start of a type.

Returns true if the token can appear at the start of a const param.

Returns true if the token can appear at the start of a generic bound.

Returns true if the token can appear at the start of an item.

Returns true if the token is any literal.

Returns true if the token is any literal, a minus (which can prefix a literal, for example a ‘-42’, or one of the boolean idents).

In other words, would this token be a valid start of parse_literal_maybe_minus?

Keep this in sync with and Lit::from_token, excluding unary negation.

Returns an identifier if this token is an identifier.

Returns a lifetime identifier if this token is a lifetime.

Returns true if the token is an identifier.

Returns true if the token is a lifetime.

Returns true if the token is an identifier whose name is the given string slice.

Returns true if the token is an interpolated path.

Would maybe_whole_expr in parser.rs return Ok(..)? That is, is this a pre-parsed expression dropped into the token stream (which happens while parsing the result of macro expansion)?

Returns true if the token is either the mut or const keyword.

Returns true if the token is a given keyword, kw.

Returns true if the token is a keyword used in the language.

Returns true if the token is a keyword reserved for possible future use.

Returns true if the token is either a special identifier or a keyword.

Returns true if the token is the identifier true or false.

Returns true if the token is a non-raw identifier for which pred holds.

Trait Implementations

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
This method tests for self and other values to be equal, and is used by ==. Read more
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more
This method tests for self and other values to be equal, and is used by ==. Read more
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.

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: 24 bytes