pub trait AstNode: Clone {
// Required methods
fn can_cast(kind: SyntaxKind) -> bool;
fn cast(syntax: SyntaxNode) -> Option<Self>
where Self: Sized;
fn syntax(&self) -> &SyntaxNode;
}Expand description
The main trait to go from untyped SyntaxNode to a typed ast. The conversion itself has zero
runtime cost; ast 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) -> bool
fn cast(syntax: SyntaxNode) -> Option<Self>where
Self: Sized,
fn syntax(&self) -> &SyntaxNode
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.