Skip to main content

AstNode

Trait AstNode 

Source
pub trait AstNode {
    type Language: Language;

    // Required methods
    fn can_cast(kind: <Self::Language as Language>::Kind) -> bool
       where Self: Sized;
    fn cast(node: SyntaxNode<Self::Language>) -> Option<Self>
       where Self: Sized;
    fn syntax(&self) -> &SyntaxNode<Self::Language>;

    // Provided methods
    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 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 Associated Types§

Required Methods§

Source

fn can_cast(kind: <Self::Language as Language>::Kind) -> bool
where Self: Sized,

Source

fn cast(node: SyntaxNode<Self::Language>) -> Option<Self>
where Self: Sized,

Source

fn syntax(&self) -> &SyntaxNode<Self::Language>

Provided Methods§

Source

fn clone_for_update(&self) -> Self
where Self: Sized,

Source

fn clone_subtree(&self) -> Self
where Self: Sized,

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl AstNode for Alert

Source§

impl AstNode for AttributeNode

Source§

impl AstNode for BlockQuote

Source§

impl AstNode for ChunkClass

Source§

impl AstNode for ChunkId

Source§

impl AstNode for ChunkLabel

Source§

impl AstNode for ChunkOption

Source§

impl AstNode for ChunkOptions

Source§

impl AstNode for Citation

Source§

impl AstNode for CodeBlock

Source§

impl AstNode for CodeInfo

Source§

impl AstNode for CodeSpan

Source§

impl AstNode for Crossref

Source§

impl AstNode for Definition

Source§

impl AstNode for DefinitionItem

Source§

impl AstNode for DefinitionList

Source§

impl AstNode for DisplayMath

Source§

impl AstNode for DivFenceClose

Source§

impl AstNode for DivFenceOpen

Source§

impl AstNode for DivInfo

Source§

impl AstNode for Document

Source§

impl AstNode for FencedDiv

Source§

impl AstNode for Figure

Source§

impl AstNode for FootnoteDefinition

Source§

impl AstNode for FootnoteReference

Source§

impl AstNode for GridTable

Source§

impl AstNode for HashpipeYamlPreamble

Source§

impl AstNode for Heading

Source§

impl AstNode for HeadingContent

Source§

impl AstNode for ImageAlt

Source§

impl AstNode for InlineFootnote

Source§

impl AstNode for InlineHtml

Source§

impl AstNode for InlineMath

Source§

impl AstNode for LatexCommand

Source§

impl AstNode for LineBlock

Source§

impl AstNode for LineBlockLine

Source§

impl AstNode for LinkDest

Source§

impl AstNode for LinkRef

Source§

impl AstNode for LinkText

Source§

impl AstNode for List

Source§

impl AstNode for ListItem

Source§

impl AstNode for MmdTitleBlock

Source§

impl AstNode for MultilineTable

Source§

impl AstNode for PandocTitleBlock

Source§

impl AstNode for Paragraph

Source§

impl AstNode for PipeTable

Source§

impl AstNode for Plain

Source§

impl AstNode for ReferenceDefinition

Source§

impl AstNode for Shortcode

Source§

impl AstNode for SimpleTable

Source§

impl AstNode for TableCaption

Source§

impl AstNode for TableCell

Source§

impl AstNode for TableRow

Source§

impl AstNode for TexBlock

Source§

impl AstNode for UnresolvedReference

Source§

impl AstNode for YamlBlockMap

Source§

impl AstNode for YamlBlockMapEntry

Source§

impl AstNode for YamlBlockMapKey

Source§

impl AstNode for YamlBlockMapValue

Source§

impl AstNode for YamlBlockSequence

Source§

impl AstNode for YamlBlockSequenceItem

Source§

impl AstNode for YamlDocument

Source§

impl AstNode for YamlFlowMap

Source§

impl AstNode for YamlFlowMapEntry

Source§

impl AstNode for YamlFlowMapKey

Source§

impl AstNode for YamlFlowMapValue

Source§

impl AstNode for YamlFlowSequence

Source§

impl AstNode for YamlFlowSequenceItem

Source§

impl AstNode for YamlMetadata