Skip to main content

Node

Trait Node 

Source
pub trait Node: Debug {
    // Required methods
    fn visit<V>(&self, visit: V)
       where V: Visit,
             Self: Sized;
    fn visit_mut<V>(&mut self, visit: V)
       where V: VisitMut;
}
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>(&self, visit: V)
where V: Visit, Self: Sized,

Traverses this node with an immutable visitor.

Source

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

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".

Implementations on Foreign Types§

Source§

impl<T> Node for &mut T
where T: Node,

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Implementors§