pub trait AstNode: Sized {
// Required methods
fn can_cast(kind: SyntaxKind) -> bool;
fn cast(syntax: SyntaxNode) -> Option<Self>;
fn syntax(&self) -> &SyntaxNode;
}Expand description
Typed wrapper around a SyntaxNode of a specific
SyntaxKind.
Required Methods§
Sourcefn can_cast(kind: SyntaxKind) -> bool
fn can_cast(kind: SyntaxKind) -> bool
Returns true iff kind is the wrapper’s expected node
kind. Used by cast and by enum dispatch.
Sourcefn cast(syntax: SyntaxNode) -> Option<Self>
fn cast(syntax: SyntaxNode) -> Option<Self>
Wrap syntax if its kind matches; otherwise None.
Sourcefn syntax(&self) -> &SyntaxNode
fn syntax(&self) -> &SyntaxNode
The underlying CST node. text() reproduces the original
bytes; children() / children_with_tokens() walk the
tree.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".