Enum rustc_expand::mbe::TokenTree[][src]

enum TokenTree {
    Token(Token),
    Delimited(DelimSpanLrc<Delimited>),
    Sequence(DelimSpanLrc<SequenceRepetition>),
    MetaVar(SpanIdent),
    MetaVarDecl(SpanIdentOption<NonterminalKind>),
}
Expand description

Similar to tokenstream::TokenTree, except that $i, $i:ident, and $(...) are “first-class” token trees. Useful for parsing macros.

Variants

Token(Token)

Tuple Fields of Token

0: Token
Delimited(DelimSpanLrc<Delimited>)

Tuple Fields of Delimited

0: DelimSpan1: Lrc<Delimited>
Sequence(DelimSpanLrc<SequenceRepetition>)

A kleene-style repetition sequence

Tuple Fields of Sequence

0: DelimSpan1: Lrc<SequenceRepetition>
MetaVar(SpanIdent)

e.g., $var

Tuple Fields of MetaVar

0: Span1: Ident
MetaVarDecl(SpanIdentOption<NonterminalKind>)

e.g., $var:expr. This is only used in the left hand side of MBE macros.

Tuple Fields of MetaVarDecl

0: Span1: Ident2: Option<NonterminalKind>

Implementations

Return the number of tokens in the tree.

Returns true if the given token tree is delimited.

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

Gets the index-th sub-token-tree. This only makes sense for delimited trees and sequences.

Retrieves the TokenTree’s span.

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 !=.

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

Performs the conversion.

Performs the conversion.

The resulting type after obtaining ownership.

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

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

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

Size for each variant: