pub trait CstToken: Sized {
// Required methods
fn can_cast(kind: SyntaxKind) -> bool;
fn cast(token: SyntaxToken) -> Option<Self>;
fn token(&self) -> &SyntaxToken;
}Expand description
Core abstraction for typed CST token wrappers
Required Methods§
Sourcefn can_cast(kind: SyntaxKind) -> bool
fn can_cast(kind: SyntaxKind) -> bool
Returns true if the given syntax kind can be cast to this token type
Sourcefn cast(token: SyntaxToken) -> Option<Self>
fn cast(token: SyntaxToken) -> Option<Self>
Attempts to cast a raw syntax token to this typed token
Returns Some(Self) if the cast is valid, None otherwise
Sourcefn token(&self) -> &SyntaxToken
fn token(&self) -> &SyntaxToken
Returns a reference to the underlying syntax token
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".