Enum rustc_ast::tokenstream::TokenTree
source · [−]pub enum TokenTree {
Token(Token),
Delimited(DelimSpan, Delimiter, 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.
Delimited(DelimSpan, Delimiter, TokenStream)
A delimited sequence of token trees.
Implementations
Trait Implementations
sourceimpl From<TokenTree> for TokenStream
impl From<TokenTree> for TokenStream
sourcefn from(tree: TokenTree) -> TokenStream
fn from(tree: TokenTree) -> TokenStream
Converts to this type from the input type.
sourceimpl From<TokenTree> for TreeAndSpacing
impl From<TokenTree> for TreeAndSpacing
sourcefn from(tree: TokenTree) -> TreeAndSpacing
fn from(tree: TokenTree) -> TreeAndSpacing
Converts to this type from the input type.
sourceimpl FromIterator<TokenTree> for TokenStream
impl FromIterator<TokenTree> for TokenStream
sourcefn from_iter<I: IntoIterator<Item = TokenTree>>(iter: I) -> Self
fn from_iter<I: IntoIterator<Item = TokenTree>>(iter: I) -> Self
Creates a value from an iterator. Read more
sourceimpl<__CTX> HashStable<__CTX> for TokenTree where
__CTX: HashStableContext,
impl<__CTX> HashStable<__CTX> for TokenTree where
__CTX: HashStableContext,
fn hash_stable(&self, __hcx: &mut __CTX, __hasher: &mut StableHasher)
impl StructuralPartialEq for TokenTree
Auto Trait Implementations
impl !RefUnwindSafe for TokenTree
impl !Send for TokenTree
impl !Sync for TokenTree
impl Unpin for TokenTree
impl !UnwindSafe for TokenTree
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. 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