Node

Trait Node 

Source
pub trait Node: Debug {
    // Required methods
    fn visit<V: Visit>(&self, visit: V)
       where Self: Sized;
    fn visit_mut<V: VisitMut>(&mut self, visit: V);
}
Expand description

A node in the statement AST that can be traversed by a visitor.

Every AST type (statements, expressions, values, etc.) implements Node to participate in the visitor pattern defined by Visit and VisitMut.

§Examples

use toasty_core::stmt::{Node, Expr, Value, visit};

let expr = Expr::from(Value::from(42_i64));
visit::for_each_expr(&expr, |e| {
    println!("{:?}", e);
});

Required Methods§

Source

fn visit<V: Visit>(&self, visit: V)
where Self: Sized,

Traverses this node with an immutable visitor.

Source

fn visit_mut<V: VisitMut>(&mut self, visit: V)

Traverses this node with a mutable visitor.

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.

Implementations on Foreign Types§

Source§

impl<T: Node> Node for Option<T>

Source§

fn visit<V: Visit>(&self, visit: V)
where Self: Sized,

Source§

fn visit_mut<V: VisitMut>(&mut self, visit: V)

Source§

impl<T: Node> Node for &mut T

Source§

fn visit<V: Visit>(&self, visit: V)
where Self: Sized,

Source§

fn visit_mut<V: VisitMut>(&mut self, visit: V)

Implementors§