[][src]Enum syntex_syntax2::tokenstream::TokenTree

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

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

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]

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

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

Retrieve the TokenTree's span.

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

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

Trait Implementations

impl ToTokens for TokenTree[src]

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 Eq for TokenTree[src]

impl Hash for TokenTree[src]

fn hash_slice<H>(data: &[Self], state: &mut H) where
    H: Hasher
1.3.0[src]

Feeds a slice of this type into the given [Hasher]. Read more

impl Debug for TokenTree[src]

impl<'de> Deserialize<'de> for TokenTree[src]

impl Serialize for TokenTree[src]

Auto Trait Implementations

impl !Sync for TokenTree

impl !Send for TokenTree

impl Unpin for TokenTree

impl !RefUnwindSafe for TokenTree

impl !UnwindSafe for TokenTree

Blanket Implementations

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

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

type Owned = T

The resulting type after obtaining ownership.

impl<T> From<T> for T[src]

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

type Error = Infallible

The type returned in the event of a conversion error.

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

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

The type returned in the event of a conversion error.

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

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

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

impl<T> DeserializeOwned for T where
    T: Deserialize<'de>, 
[src]