Enum rustc_ap_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 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.
Delimited(DelimSpan, DelimToken, TokenStream)A delimited sequence of token trees.
Implementations
impl TokenTree[src]
impl TokenTree[src]pub fn eq_unspanned(&self, other: &TokenTree) -> bool[src]
pub fn eq_unspanned(&self, other: &TokenTree) -> bool[src]Checks if this TokenTree is equal to the other, regardless of span information.
pub fn token(kind: TokenKind, span: Span) -> TokenTree[src]
pub fn open_tt(span: DelimSpan, delim: DelimToken) -> TokenTree[src]
pub fn open_tt(span: DelimSpan, delim: DelimToken) -> TokenTree[src]Returns the opening delimiter as a token tree.
pub fn close_tt(span: DelimSpan, delim: DelimToken) -> TokenTree[src]
pub fn close_tt(span: DelimSpan, delim: DelimToken) -> TokenTree[src]Returns the closing delimiter as a token tree.
pub fn uninterpolate(self) -> TokenTree[src]
Trait Implementations
impl From<TokenTree> for TokenStream[src]
impl From<TokenTree> for TokenStream[src]fn from(tree: TokenTree) -> TokenStream[src]
fn from(tree: TokenTree) -> TokenStream[src]Performs the conversion.
impl From<TokenTree> for TreeAndSpacing[src]
impl From<TokenTree> for TreeAndSpacing[src]fn from(tree: TokenTree) -> TreeAndSpacing[src]
fn from(tree: TokenTree) -> TreeAndSpacing[src]Performs the conversion.
impl FromIterator<TokenTree> for TokenStream[src]
impl FromIterator<TokenTree> for TokenStream[src]fn from_iter<I: IntoIterator<Item = TokenTree>>(iter: I) -> Self[src]
fn from_iter<I: IntoIterator<Item = TokenTree>>(iter: I) -> Self[src]Creates a value from an iterator. Read more
impl<__CTX> HashStable<__CTX> for TokenTree where
__CTX: HashStableContext, [src]
impl<__CTX> HashStable<__CTX> for TokenTree where
__CTX: HashStableContext, [src]fn hash_stable(&self, __hcx: &mut __CTX, __hasher: &mut StableHasher)[src]
impl StructuralPartialEq for TokenTree[src]
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
impl<T> BorrowMut<T> for T where
T: ?Sized, [src]
impl<T> BorrowMut<T> for T where
T: ?Sized, [src]pub fn borrow_mut(&mut self) -> &mut T[src]
pub fn borrow_mut(&mut self) -> &mut T[src]Mutably borrows from an owned value. Read more
impl<T> Instrument for T[src]
impl<T> Instrument for T[src]fn instrument(self, span: Span) -> Instrumented<Self>[src]
fn instrument(self, span: Span) -> Instrumented<Self>[src]Instruments this type with the provided Span, returning an
Instrumented wrapper. Read more
fn in_current_span(self) -> Instrumented<Self>[src]
fn in_current_span(self) -> Instrumented<Self>[src]impl<T> Same<T> for T
impl<T> Same<T> for Ttype Output = T
type Output = TShould always be Self
impl<T> ToOwned for T where
T: Clone, [src]
impl<T> ToOwned for T where
T: Clone, [src]type Owned = T
type Owned = TThe resulting type after obtaining ownership.
pub fn to_owned(&self) -> T[src]
pub fn to_owned(&self) -> T[src]Creates owned data from borrowed data, usually by cloning. Read more
pub fn clone_into(&self, target: &mut T)[src]
pub fn clone_into(&self, target: &mut T)[src]🔬 This is a nightly-only experimental API. (toowned_clone_into)
recently added
Uses borrowed data to replace owned data, usually by cloning. Read more
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
impl<V, T> VZip<V> for T where
V: MultiLane<T>, pub fn vzip(self) -> V
impl<'a, T> Captures<'a> for T where
T: ?Sized, [src]
T: ?Sized,