Skip to main content

CstNode

Trait CstNode 

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

Source

fn can_cast(kind: SyntaxKind) -> bool

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

Source

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

Source

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

Implementors§