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