[][src]Enum syntax::tokenstream::TokenTree

pub enum TokenTree {
    Token(SpanToken),
    Delimited(DelimSpanDelimTokenTokenStream),
}

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(SpanToken)

A single token

Delimited(DelimSpanDelimTokenTokenStream)

A delimited sequence of token trees

Methods

impl TokenTree[src]

pub fn parse(
    cx: &ExtCtxt,
    mtch: &[TokenTree],
    tts: TokenStream
) -> NamedParseResult
[src]

Use this token tree as a matcher to parse given tts.

pub fn eq_unspanned(&self, other: &TokenTree) -> bool[src]

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

pub fn probably_equal_for_proc_macro(&self, other: &TokenTree) -> bool[src]

pub fn span(&self) -> Span[src]

Retrieves the TokenTree's span.

pub fn set_span(&mut self, span: Span)[src]

Modify the TokenTree's span in-place.

pub fn eq_token(&self, t: Token) -> bool[src]

Indicates if the stream is a token that is equal to the provided token.

pub fn joint(self) -> TokenStream[src]

pub fn open_tt(span: Span, delim: DelimToken) -> TokenTree[src]

Returns the opening delimiter as a token tree.

pub fn close_tt(span: Span, delim: DelimToken) -> TokenTree[src]

Returns the closing delimiter as a token tree.

Trait Implementations

impl PartialEq<TokenTree> for TokenTree[src]

impl Clone for TokenTree[src]

fn clone_from(&mut self, source: &Self)
1.0.0
[src]

Performs copy-assignment from source. Read more

impl From<TokenTree> for TokenStream[src]

impl From<TokenTree> for TreeAndJoint[src]

impl Debug for TokenTree[src]

impl Encodable for TokenTree[src]

impl Decodable for TokenTree[src]

Auto Trait Implementations

impl !Send for TokenTree

impl !Sync for TokenTree

Blanket Implementations

impl<T> From for T[src]

impl<T, U> Into for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

impl<T, U> TryFrom for T where
    U: Into<T>, 
[src]

type Error = !

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

The type returned in the event of a conversion error.

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> BorrowMut for T where
    T: ?Sized
[src]

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

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

The type returned in the event of a conversion error.

impl<T> Encodable for T where
    T: UseSpecializedEncodable + ?Sized
[src]

impl<T> Decodable for T where
    T: UseSpecializedDecodable
[src]

impl<E> SpecializationError for E[src]

impl<T> Send for T where
    T: ?Sized
[src]

impl<T> Sync for T where
    T: ?Sized
[src]

impl<T> Erased for T[src]