moonlander_gp

Trait AstNode

Source
pub trait AstNode:
    Any
    + Mutatable
    + Copyable
    + Sync {
    // Required methods
    fn node_type(&self) -> usize;
    fn children(&self) -> Vec<&dyn AstNode>;
    fn replace_child(
        &self,
        old_child: &dyn AstNode,
        new_child: &mut Option<Box<dyn AstNode>>,
    ) -> Box<dyn AstNode>;
}
Expand description

Main trait to be implemented for AST node types

Required Methods§

Source

fn node_type(&self) -> usize

Identify the node type, because Any::get_type_id() is unstable.

Source

fn children(&self) -> Vec<&dyn AstNode>

Return all children of this node.

Source

fn replace_child( &self, old_child: &dyn AstNode, new_child: &mut Option<Box<dyn AstNode>>, ) -> Box<dyn AstNode>

Return a copy of this node with a single child node replaced.

Implementations§

Source§

impl dyn AstNode

Source

pub fn is<T>(&self) -> bool
where T: Any, Self: Downcast<T>,

Source

pub unsafe fn downcast_ref_unchecked<T>(&self) -> &T
where T: Any, Self: Downcast<T>,

Source

pub fn downcast_ref<T>(&self) -> Option<&T>
where T: Any, Self: Downcast<T>,

Source

pub unsafe fn downcast_mut_unchecked<T>(&mut self) -> &mut T
where T: Any, Self: Downcast<T>,

Source

pub fn downcast_mut<T>(&mut self) -> Option<&mut T>
where T: Any, Self: Downcast<T>,

Source

pub unsafe fn unchecked_downcast<T>(self: Box<Self>) -> Box<T>
where T: Any, Self: Downcast<T>,

Source

pub fn downcast<T>(self: Box<Self>) -> Result<Box<T>, Box<Self>>
where T: Any, Self: Downcast<T>,

Trait Implementations§

Source§

impl<T> Downcast<T> for dyn AstNode
where T: AstNode,

Source§

fn is_type(&self) -> bool

Source§

unsafe fn downcast_ref_unchecked(&self) -> &T

Source§

unsafe fn downcast_mut_unchecked(&mut self) -> &mut T

Source§

unsafe fn unchecked_downcast(self: Box<Self>) -> Box<T>

Source§

fn downcast_ref(&self) -> Option<&T>

Source§

fn downcast_mut(&mut self) -> Option<&mut T>

Source§

fn downcast(self: Box<Self>) -> Result<Box<T>, Box<Self>>

Implementors§