pub trait AstToken: Sized {
// Required methods
fn can_cast(kind: SyntaxKind) -> bool;
fn cast(token: SyntaxToken) -> Option<Self>;
fn syntax(&self) -> &SyntaxToken;
// Provided method
fn text(&self) -> &str { ... }
}Expand description
Typed wrapper around a SyntaxToken of a specific
SyntaxKind. Like AstNode but for leaf tokens.
Required Methods§
fn can_cast(kind: SyntaxKind) -> bool
fn cast(token: SyntaxToken) -> Option<Self>
fn syntax(&self) -> &SyntaxToken
Provided Methods§
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".