[−][src]Enum rustc_expand::mbe::TokenTree

pub(in mbe) enum TokenTree {
    Token(Token),
    Delimited(DelimSpan, Lrc<Delimited>),
    Sequence(DelimSpan, Lrc<SequenceRepetition>),
    MetaVar(Span, Ident),
    MetaVarDecl(Span, Ident, NonterminalKind),
}

Similar to tokenstream::TokenTree, except that $i, $i:ident, and $(...) are "first-class" token trees. Useful for parsing macros.

Variants

Token(Token)
Delimited(DelimSpan, Lrc<Delimited>)
Sequence(DelimSpan, Lrc<SequenceRepetition>)

A kleene-style repetition sequence

MetaVar(Span, Ident)

e.g., $var

MetaVarDecl(Span, Ident, NonterminalKind)

e.g., $var:expr. This is only used in the left hand side of MBE macros.

Implementations

impl TokenTree[src]

pub(in mbe) fn len(
    &self
) -> usize
[src]

Return the number of tokens in the tree.

pub(in mbe) fn is_delimited(
    &self
) -> bool
[src]

Returns true if the given token tree is delimited.

pub(in mbe) fn is_token(
    &self,
    expected_kind: &TokenKind
) -> bool
[src]

Returns true if the given token tree is a token of the given kind.

pub(in mbe) fn get_tt(
    &self,
    index: usize
) -> TokenTree
[src]

Gets the index-th sub-token-tree. This only makes sense for delimited trees and sequences.

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

Retrieves the TokenTree's span.

pub(in mbe) fn token(
    kind: TokenKind,
    span: Span
) -> TokenTree
[src]

Trait Implementations

impl Clone for TokenTree[src]

impl Debug for TokenTree[src]

impl<__D: Decoder> Decodable<__D> for TokenTree[src]

impl<__E: Encoder> Encodable<__E> for TokenTree[src]

impl PartialEq<TokenTree> for TokenTree[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> Any for T where
    T: 'static + ?Sized, 
[src]

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

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

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

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, 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.