enum TokenTree {
    Token(Token),
    Delimited(DelimSpanDelimited),
    Sequence(DelimSpanSequenceRepetition),
    MetaVar(SpanIdent),
    MetaVarDecl(SpanIdentOption<NonterminalKind>),
    MetaVarExpr(DelimSpanMetaVarExpr),
}
Expand description

Similar to tokenstream::TokenTree, except that Sequence, MetaVar, MetaVarDecl, and MetaVarExpr are “first-class” token trees. Useful for parsing macros.

Variants

Token(Token)

Delimited(DelimSpanDelimited)

A delimited sequence, e.g. ($e:expr) (RHS) or { $e } (LHS).

Sequence(DelimSpanSequenceRepetition)

A kleene-style repetition sequence, e.g. $($e:expr)* (RHS) or $($e),* (LHS).

MetaVar(SpanIdent)

e.g., $var.

MetaVarDecl(SpanIdentOption<NonterminalKind>)

e.g., $var:expr. Only appears on the LHS.

MetaVarExpr(DelimSpanMetaVarExpr)

A meta-variable expression inside ${...}.

Implementations

Returns true if the given token tree is delimited.

Returns true if the given token tree is a token of the given kind.

Retrieves the TokenTree’s span.

Trait Implementations

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

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

Size for each variant:

  • Token: 24 bytes
  • Delimited: 48 bytes
  • Sequence: 88 bytes
  • MetaVar: 20 bytes
  • MetaVarDecl: 24 bytes
  • MetaVarExpr: 48 bytes