Skip to main content

CstToken

Trait CstToken 

Source
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§

Source

fn can_cast(kind: SyntaxKind) -> bool

Returns true if the given syntax kind can be cast to this token type

Source

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

Source

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".

Implementors§