Enum rustc_ap_rustc_ast::tokenstream::TokenTree[][src]

pub enum TokenTree {
    Token(Token),
    Delimited(DelimSpanDelimTokenTokenStream),
}
Expand description

When the main Rust parser encounters a syntax-extension invocation, it parses the arguments to the invocation as a token tree. This is a very loose structure, such that all sorts of different AST fragments can be passed to syntax extensions using a uniform type.

If the syntax extension is an MBE macro, it will attempt to match its LHS token tree against the provided token tree, and if it finds a match, will transcribe the RHS token tree, splicing in any captured macro_parser::matched_nonterminals into the SubstNts it finds.

The RHS of an MBE macro is the only place SubstNts are substituted. Nothing special happens to misnamed or misplaced SubstNts.

Variants

Token(Token)

A single token.

A delimited sequence of token trees.

Implementations

Checks if this TokenTree is equal to the other, regardless of span information.

Retrieves the TokenTree’s span.

Modify the TokenTree’s span in-place.

Returns the opening delimiter as a token tree.

Returns the closing delimiter as a token tree.

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

Performs the conversion.

Performs the conversion.

Creates a value from an iterator. 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.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more

Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Performs the conversion.

Should always be Self

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.