Trait proclet::TokenTreeExt

source ·
pub trait TokenTreeExt: ProcMacroExt<TokenTreeExt = Self> + TokenTree + Parse<Self> + IntoTokens<Self> + ToTokens<Self> + ToTokenStream<Self::TokenStreamExt> {
Show 18 methods // Required methods fn kind(&self) -> TokenTreeKind; fn group(&self) -> Option<&Self::Group>; fn group_mut(&mut self) -> Option<&mut Self::Group>; fn into_group(self) -> Option<Self::Group>; fn ident(&self) -> Option<&Self::Ident>; fn ident_mut(&mut self) -> Option<&mut Self::Ident>; fn into_ident(self) -> Option<Self::Ident>; fn punct(&self) -> Option<&Self::Punct>; fn punct_mut(&mut self) -> Option<&mut Self::Punct>; fn into_punct(self) -> Option<Self::Punct>; fn literal(&self) -> Option<&Self::Literal>; fn literal_mut(&mut self) -> Option<&mut Self::Literal>; fn into_literal(self) -> Option<Self::Literal>; // Provided methods fn is_group(&self) -> bool { ... } fn is_ident(&self) -> bool { ... } fn is_punct(&self) -> bool { ... } fn is_literal(&self) -> bool { ... } fn flatten_group(&mut self) { ... }
}
Expand description

Extensions for TokenTree.

This trait is implemented for TokenTree in proc_macro and proc_macro2 if the corresponding feature is enabled.

Required Methods§

source

fn kind(&self) -> TokenTreeKind

Get the kind of this TokenTree.

source

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

If this TokenTree is a TokenTree::Group, return a reference to the Group.

source

fn group_mut(&mut self) -> Option<&mut Self::Group>

If this TokenTree is a TokenTree::Group, return a mutable reference to the Group.

source

fn into_group(self) -> Option<Self::Group>

If this TokenTree is a TokenTree::Group, return the Group.

source

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

If this TokenTree is a TokenTree::Ident, return a reference to the Ident.

source

fn ident_mut(&mut self) -> Option<&mut Self::Ident>

If this TokenTree is a TokenTree::Ident, return a mutable reference to the Ident.

source

fn into_ident(self) -> Option<Self::Ident>

If this TokenTree is a TokenTree::Ident, return the Ident.

source

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

If this TokenTree is a TokenTree::Punct, return a reference to the Punct.

source

fn punct_mut(&mut self) -> Option<&mut Self::Punct>

If this TokenTree is a TokenTree::Punct, return a mutable reference to the Punct.

source

fn into_punct(self) -> Option<Self::Punct>

Check if this TokenTree is a TokenTree::Punct.

source

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

If this TokenTree is a TokenTree::Literal, return a reference to the Literal.

source

fn literal_mut(&mut self) -> Option<&mut Self::Literal>

If this TokenTree is a TokenTree::Literal, return a mutable reference to the Literal.

source

fn into_literal(self) -> Option<Self::Literal>

Check if this TokenTree is a TokenTree::Literal.

Provided Methods§

source

fn is_group(&self) -> bool

Check if this TokenTree is a TokenTree::Group.

source

fn is_ident(&self) -> bool

Check if this TokenTree is a TokenTree::Ident.

source

fn is_punct(&self) -> bool

Check if this TokenTree is a TokenTree::Punct.

source

fn is_literal(&self) -> bool

Check if this TokenTree is a TokenTree::Literal.

source

fn flatten_group(&mut self)

If the TokenTree is a group with delimiter None containing a single item, replace the group with that item, recursively.

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl TokenTreeExt for TokenTree

Available on crate feature proc-macro only.
source§

fn kind(&self) -> TokenTreeKind

source§

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

source§

fn group_mut(&mut self) -> Option<&mut <Self as ProcMacro>::Group>

source§

fn into_group(self) -> Option<<Self as ProcMacro>::Group>

source§

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

source§

fn ident_mut(&mut self) -> Option<&mut <Self as ProcMacro>::Ident>

source§

fn into_ident(self) -> Option<<Self as ProcMacro>::Ident>

source§

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

source§

fn punct_mut(&mut self) -> Option<&mut <Self as ProcMacro>::Punct>

source§

fn into_punct(self) -> Option<<Self as ProcMacro>::Punct>

source§

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

source§

fn literal_mut(&mut self) -> Option<&mut <Self as ProcMacro>::Literal>

source§

fn into_literal(self) -> Option<<Self as ProcMacro>::Literal>

source§

impl TokenTreeExt for TokenTree

Available on crate feature proc-macro2 only.
source§

fn kind(&self) -> TokenTreeKind

source§

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

source§

fn group_mut(&mut self) -> Option<&mut <Self as ProcMacro>::Group>

source§

fn into_group(self) -> Option<<Self as ProcMacro>::Group>

source§

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

source§

fn ident_mut(&mut self) -> Option<&mut <Self as ProcMacro>::Ident>

source§

fn into_ident(self) -> Option<<Self as ProcMacro>::Ident>

source§

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

source§

fn punct_mut(&mut self) -> Option<&mut <Self as ProcMacro>::Punct>

source§

fn into_punct(self) -> Option<<Self as ProcMacro>::Punct>

source§

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

source§

fn literal_mut(&mut self) -> Option<&mut <Self as ProcMacro>::Literal>

source§

fn into_literal(self) -> Option<<Self as ProcMacro>::Literal>

Implementors§