pub trait TreeNodeRewriter: Sized {
    type N: TreeNode;

    // Required method
    fn mutate(&mut self, node: Self::N) -> Result<Self::N>;

    // Provided method
    fn pre_visit(&mut self, _node: &Self::N) -> Result<RewriteRecursion> { ... }
}
Expand description

Trait for potentially recursively transform an TreeNode node tree. When passed to TreeNode::rewrite, TreeNodeRewriter::mutate is invoked recursively on all nodes of a tree.

Required Associated Types§

source

type N: TreeNode

The node type which is rewritable.

Required Methods§

source

fn mutate(&mut self, node: Self::N) -> Result<Self::N>

Invoked after (Postorder) all children of node have been mutated and returns a potentially modified node.

Provided Methods§

source

fn pre_visit(&mut self, _node: &Self::N) -> Result<RewriteRecursion>

Invoked before (Preorder) any children of node are rewritten / visited. Default implementation returns Ok(Recursion::Continue)

Implementors§