pub trait TokenTreeExt: Sized + Sealed {
Show 13 methods
// Required methods
fn equals(&self, other: &Self) -> bool;
fn is_group(&self) -> bool;
fn is_ident(&self) -> bool;
fn is_punct(&self) -> bool;
fn is_literal(&self) -> bool;
fn into_group(self) -> Result<Group, Self>;
fn into_ident(self) -> Result<Ident, Self>;
fn into_punct(self) -> Result<Punct, Self>;
fn into_literal(self) -> Result<Literal, Self>;
fn as_group(&self) -> Option<&Group>;
fn as_ident(&self) -> Option<&Ident>;
fn as_punct(&self) -> Option<&Punct>;
fn as_literal(&self) -> Option<&Literal>;
}Expand description
Extension trait for TokenTree.
Required Methods§
Sourcefn is_literal(&self) -> bool
fn is_literal(&self) -> bool
Checks if the token tree is a literal.
Sourcefn into_group(self) -> Result<Group, Self>
fn into_group(self) -> Result<Group, Self>
Require the token tree to be a group.
Sourcefn into_ident(self) -> Result<Ident, Self>
fn into_ident(self) -> Result<Ident, Self>
Require the token tree to be an ident.
Sourcefn into_punct(self) -> Result<Punct, Self>
fn into_punct(self) -> Result<Punct, Self>
Require the token tree to be a punct.
Sourcefn into_literal(self) -> Result<Literal, Self>
fn into_literal(self) -> Result<Literal, Self>
Require the token tree to be a literal.
Sourcefn as_literal(&self) -> Option<&Literal>
fn as_literal(&self) -> Option<&Literal>
Returns the token tree as a literal if it is one.
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.