Enum rustc_ast::tokenstream::TokenTree [−][src]
pub enum TokenTree {
Token(Token),
Delimited(DelimSpan, DelimToken, TokenStream),
}
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 SubstNt
s it finds.
The RHS of an MBE macro is the only place SubstNt
s are substituted.
Nothing special happens to misnamed or misplaced SubstNt
s.
Variants
Token(Token)
A single token.
Tuple Fields of Token
0: Token
Delimited(DelimSpan, DelimToken, TokenStream)
A delimited sequence of token trees.
Tuple Fields of Delimited
Implementations
Checks if this TokenTree
is equal to the other, regardless of span information.
Returns the opening delimiter as a token tree.
Returns the closing delimiter as a token tree.
Trait Implementations
Auto Trait Implementations
impl !RefUnwindSafe for TokenTree
impl !UnwindSafe for TokenTree
Blanket Implementations
Mutably borrows from an owned value. Read more
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:
Token
: 31 bytesDelimited
: 31 bytes