pub trait CstNode {
// Required methods
fn can_cast(kind: SyntaxKind) -> bool
where Self: Sized;
fn cast(syntax: SyntaxNode) -> Option<Self>
where Self: Sized;
fn syntax(&self) -> &SyntaxNode;
// Provided methods
fn source_string(&self) -> String { ... }
fn clone_for_update(&self) -> Self
where Self: Sized { ... }
fn clone_subtree(&self) -> Self
where Self: Sized { ... }
}Expand description
The main trait to go from untyped SyntaxNode to a typed CST. The
conversion itself has zero runtime cost: CST and syntax nodes have exactly
the same representation: a pointer to the tree root and a pointer to the
node itself.
Required Methods§
fn can_cast(kind: SyntaxKind) -> boolwhere
Self: Sized,
fn cast(syntax: SyntaxNode) -> Option<Self>where
Self: Sized,
fn syntax(&self) -> &SyntaxNode
Provided Methods§
fn source_string(&self) -> String
fn clone_for_update(&self) -> Selfwhere
Self: Sized,
fn clone_subtree(&self) -> Selfwhere
Self: Sized,
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".