Trait Visitor

Source
pub trait Visitor<'tree> {
    type Error;

    // Required method
    fn visit_node(&self, node: Node<'tree>) -> Result<bool, Self::Error>;
}
Expand description

Trait used to enable visiting members of KCL AST.

Implementing this trait enables the implementer to be invoked over members of KCL AST by using the Visitable::visit function on a Node.

Required Associated Types§

Source

type Error

Error type returned by the [Self::visit] function.

Required Methods§

Source

fn visit_node(&self, node: Node<'tree>) -> Result<bool, Self::Error>

Visit a KCL AST Node.

In general, implementers likely wish to check to see if a Node is what they’re looking for, and either descend into that Node’s children (by calling Visitable::children on Node to get children nodes, calling Visitable::visit on each node of interest), or perform some action.

Implementors§

Source§

impl<'a, FnT, ErrorT> Visitor<'a> for FnT
where FnT: Fn(Node<'a>) -> Result<bool, ErrorT>,

Source§

type Error = ErrorT