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.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.
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.