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§
sourcefn kind(&self) -> TokenTreeKind
fn kind(&self) -> TokenTreeKind
Get the kind of this TokenTree
.
sourcefn group(&self) -> Option<&Self::Group>
fn group(&self) -> Option<&Self::Group>
If this TokenTree
is a TokenTree::Group
, return a reference to the Group
.
sourcefn group_mut(&mut self) -> Option<&mut Self::Group>
fn group_mut(&mut self) -> Option<&mut Self::Group>
If this TokenTree
is a TokenTree::Group
, return a mutable reference to the Group
.
sourcefn into_group(self) -> Option<Self::Group>
fn into_group(self) -> Option<Self::Group>
If this TokenTree
is a TokenTree::Group
, return the Group
.
sourcefn ident(&self) -> Option<&Self::Ident>
fn ident(&self) -> Option<&Self::Ident>
If this TokenTree
is a TokenTree::Ident
, return a reference to the Ident
.
sourcefn ident_mut(&mut self) -> Option<&mut Self::Ident>
fn ident_mut(&mut self) -> Option<&mut Self::Ident>
If this TokenTree
is a TokenTree::Ident
, return a mutable reference to the Ident
.
sourcefn into_ident(self) -> Option<Self::Ident>
fn into_ident(self) -> Option<Self::Ident>
If this TokenTree
is a TokenTree::Ident
, return the Ident
.
sourcefn punct(&self) -> Option<&Self::Punct>
fn punct(&self) -> Option<&Self::Punct>
If this TokenTree
is a TokenTree::Punct
, return a reference to the Punct
.
sourcefn punct_mut(&mut self) -> Option<&mut Self::Punct>
fn punct_mut(&mut self) -> Option<&mut Self::Punct>
If this TokenTree
is a TokenTree::Punct
, return a mutable reference to the Punct
.
sourcefn into_punct(self) -> Option<Self::Punct>
fn into_punct(self) -> Option<Self::Punct>
Check if this TokenTree
is a TokenTree::Punct
.
sourcefn literal(&self) -> Option<&Self::Literal>
fn literal(&self) -> Option<&Self::Literal>
If this TokenTree
is a TokenTree::Literal
, return a reference to the Literal
.
sourcefn literal_mut(&mut self) -> Option<&mut Self::Literal>
fn literal_mut(&mut self) -> Option<&mut Self::Literal>
If this TokenTree
is a TokenTree::Literal
, return a mutable reference to the Literal
.
sourcefn into_literal(self) -> Option<Self::Literal>
fn into_literal(self) -> Option<Self::Literal>
Check if this TokenTree
is a TokenTree::Literal
.
Provided Methods§
sourcefn is_literal(&self) -> bool
fn is_literal(&self) -> bool
Check if this TokenTree
is a TokenTree::Literal
.
sourcefn flatten_group(&mut self)
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§
Implementations on Foreign Types§
source§impl TokenTreeExt for TokenTree
Available on crate feature proc-macro
only.
impl TokenTreeExt for TokenTree
proc-macro
only.fn kind(&self) -> TokenTreeKind
fn group(&self) -> Option<&<Self as ProcMacro>::Group>
fn group_mut(&mut self) -> Option<&mut <Self as ProcMacro>::Group>
fn into_group(self) -> Option<<Self as ProcMacro>::Group>
fn ident(&self) -> Option<&<Self as ProcMacro>::Ident>
fn ident_mut(&mut self) -> Option<&mut <Self as ProcMacro>::Ident>
fn into_ident(self) -> Option<<Self as ProcMacro>::Ident>
fn punct(&self) -> Option<&<Self as ProcMacro>::Punct>
fn punct_mut(&mut self) -> Option<&mut <Self as ProcMacro>::Punct>
fn into_punct(self) -> Option<<Self as ProcMacro>::Punct>
fn literal(&self) -> Option<&<Self as ProcMacro>::Literal>
fn literal_mut(&mut self) -> Option<&mut <Self as ProcMacro>::Literal>
fn into_literal(self) -> Option<<Self as ProcMacro>::Literal>
source§impl TokenTreeExt for TokenTree
Available on crate feature proc-macro2
only.
impl TokenTreeExt for TokenTree
proc-macro2
only.