pub trait TreeNodeVisitor: Sized {
    type Node: TreeNode;

    // Provided methods
    fn f_down(&mut self, _node: &Self::Node) -> Result<TreeNodeRecursion> { ... }
    fn f_up(&mut self, _node: &Self::Node) -> Result<TreeNodeRecursion> { ... }
}
Expand description

Implements the visitor pattern for recursively walking TreeNodes.

A TreeNodeVisitor allows one to express algorithms separately from the code traversing the structure of the TreeNode tree, making it easier to add new types of tree nodes and algorithms.

When passed to TreeNode::visit, TreeNodeVisitor::f_down and TreeNodeVisitor::f_up are invoked recursively on the tree. See TreeNodeRecursion for more details on controlling the traversal.

Required Associated Types§

source

type Node: TreeNode

The node type which is visitable.

Provided Methods§

source

fn f_down(&mut self, _node: &Self::Node) -> Result<TreeNodeRecursion>

Invoked before any children of node are visited. Default implementation simply continues the recursion.

source

fn f_up(&mut self, _node: &Self::Node) -> Result<TreeNodeRecursion>

Invoked after all children of node are visited. Default implementation simply continues the recursion.

Object Safety§

This trait is not object safe.

Implementors§