pub trait TokenTreeExt {
    type Group;
    type Ident;
    type Punct;
    type Literal;

    // Required methods
    fn is_group(&self) -> bool;
    fn group(self) -> Option<<Self as TokenTreeExt>::Group>;
    fn is_ident(&self) -> bool;
    fn ident(self) -> Option<<Self as TokenTreeExt>::Ident>;
    fn is_punct(&self) -> bool;
    fn punct(self) -> Option<<Self as TokenTreeExt>::Punct>;
    fn is_literal(&self) -> bool;
    fn literal(self) -> Option<<Self as TokenTreeExt>::Literal>;
}
Expand description

Generic extensions for proc_macro::TokenTree and proc_macro2::TokenTree

Required Associated Types§

source

type Group

Group of this TokenTree, necessary to support both TokenTrees

source

type Ident

Ident of this TokenTree, necessary to support both TokenTrees

source

type Punct

Punct of this TokenTree, necessary to support both TokenTrees

source

type Literal

Literal of this TokenTree, necessary to support both TokenTrees

Required Methods§

source

fn is_group(&self) -> bool

Tests if the token tree is a group.

source

fn group(self) -> Option<<Self as TokenTreeExt>::Group>

Get the Group inside this token tree, or None if it isn’t a group.

source

fn is_ident(&self) -> bool

Tests if the token tree is an ident.

source

fn ident(self) -> Option<<Self as TokenTreeExt>::Ident>

Get the Ident inside this token tree, or None if it isn’t an ident.

source

fn is_punct(&self) -> bool

Tests if the token tree is a punctuation.

source

fn punct(self) -> Option<<Self as TokenTreeExt>::Punct>

Get the Punct inside this token tree, or None if it isn’t a punctuation.

source

fn is_literal(&self) -> bool

Tests if the token tree is a literal.

source

fn literal(self) -> Option<<Self as TokenTreeExt>::Literal>

Get the Literal inside this token tree, or None if it isn’t a literal.

Implementations on Foreign Types§

source§

impl TokenTreeExt for TokenTree

§

type Group = Group

§

type Ident = Ident

§

type Punct = Punct

§

type Literal = Literal

source§

fn is_group(&self) -> bool

source§

fn group(self) -> Option<<Self as TokenTreeExt>::Group>

source§

fn is_ident(&self) -> bool

source§

fn ident(self) -> Option<<Self as TokenTreeExt>::Ident>

source§

fn is_punct(&self) -> bool

source§

fn punct(self) -> Option<<Self as TokenTreeExt>::Punct>

source§

fn is_literal(&self) -> bool

source§

fn literal(self) -> Option<<Self as TokenTreeExt>::Literal>

source§

impl TokenTreeExt for TokenTree

§

type Group = Group

§

type Ident = Ident

§

type Punct = Punct

§

type Literal = Literal

source§

fn is_group(&self) -> bool

source§

fn group(self) -> Option<<Self as TokenTreeExt>::Group>

source§

fn is_ident(&self) -> bool

source§

fn ident(self) -> Option<<Self as TokenTreeExt>::Ident>

source§

fn is_punct(&self) -> bool

source§

fn punct(self) -> Option<<Self as TokenTreeExt>::Punct>

source§

fn is_literal(&self) -> bool

source§

fn literal(self) -> Option<<Self as TokenTreeExt>::Literal>

Implementors§