pub trait TokenTree2Ext {
    // Required methods
    fn is_group(&self) -> bool;
    fn group(&self) -> Option<&Group>;
    fn into_group(self) -> Option<Group>;
    fn is_ident(&self) -> bool;
    fn ident(&self) -> Option<&Ident>;
    fn into_ident(self) -> Option<Ident>;
    fn is_punct(&self) -> bool;
    fn punct(&self) -> Option<&Punct>;
    fn into_punct(self) -> Option<Punct>;
    fn is_literal(&self) -> bool;
    fn literal(&self) -> Option<&Literal>;
    fn into_literal(self) -> Option<Literal>;
}
Available on crate feature proc-macro2 only.
Expand description

Generic extensions for proc_macro2::TokenTree

Required Methods§

source

fn is_group(&self) -> bool

Tests if the token tree is a group.

source

fn group(&self) -> Option<&Group>

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

source

fn into_group(self) -> Option<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<&Ident>

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

source

fn into_ident(self) -> Option<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<&Punct>

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

source

fn into_punct(self) -> Option<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<&Literal>

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

source

fn into_literal(self) -> Option<Literal>

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

Implementations on Foreign Types§

source§

impl TokenTree2Ext for TokenTree

source§

fn is_group(&self) -> bool

Tests if the token tree is a group.

source§

fn group(&self) -> Option<&Group>

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

source§

fn into_group(self) -> Option<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<&Ident>

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

source§

fn into_ident(self) -> Option<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<&Punct>

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

source§

fn into_punct(self) -> Option<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<&Literal>

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

source§

fn into_literal(self) -> Option<Literal>

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

Implementors§