pub trait TokenType:
Copy
+ Eq
+ Hash
+ Send
+ Sync
+ Debug
+ Serialize
+ for<'de> Deserialize<'de> {
type Role: TokenRole;
const END_OF_STREAM: Self;
// Required method
fn role(&self) -> Self::Role;
// Provided methods
fn is_role(&self, role: Self::Role) -> bool { ... }
fn is_universal(&self, role: UniversalTokenRole) -> bool { ... }
fn is_comment(&self) -> bool { ... }
fn is_whitespace(&self) -> bool { ... }
fn is_error(&self) -> bool { ... }
fn is_ignored(&self) -> bool { ... }
fn is_end_of_stream(&self) -> bool { ... }
}Expand description
A trait for types that represent a token’s kind in a specific language.
Required Associated Constants§
Sourceconst END_OF_STREAM: Self
const END_OF_STREAM: Self
A constant representing the end of the input stream.
Required Associated Types§
Required Methods§
Provided Methods§
Sourcefn is_role(&self, role: Self::Role) -> bool
fn is_role(&self, role: Self::Role) -> bool
Returns true if this token matches the specified language-specific role.
Sourcefn is_universal(&self, role: UniversalTokenRole) -> bool
fn is_universal(&self, role: UniversalTokenRole) -> bool
Returns true if this token matches the specified universal role.
Sourcefn is_comment(&self) -> bool
fn is_comment(&self) -> bool
Returns true if this token represents a comment.
Sourcefn is_whitespace(&self) -> bool
fn is_whitespace(&self) -> bool
Returns true if this token represents whitespace.
Sourcefn is_ignored(&self) -> bool
fn is_ignored(&self) -> bool
Returns true if this token represents trivia (whitespace, comments, etc.).
Sourcefn is_end_of_stream(&self) -> bool
fn is_end_of_stream(&self) -> bool
Returns true if this token represents the end of the input stream.
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.