pub trait Token: Spanned + Sized {
const SPELLING: &'static str;
// Required methods
fn matches_token_tree(token: &TokenTree) -> bool;
fn from_token_tree(token: TokenTree) -> Option<Self>;
}Expand description
A generated closed token atom backed by one matching raw TokenTree.
Parsing validates the raw category and spelling, then retains the raw atom so emission preserves its source text and span.
Required Associated Constants§
Required Methods§
Sourcefn matches_token_tree(token: &TokenTree) -> bool
fn matches_token_tree(token: &TokenTree) -> bool
Tests whether a raw atom belongs to this closed token type.
Sourcefn from_token_tree(token: TokenTree) -> Option<Self>
fn from_token_tree(token: TokenTree) -> Option<Self>
Validates and retains a raw atom as this typed token.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".