pub trait Endo<T: Tree> {
// Required method
fn apply(&mut self, t: T) -> T;
// Provided methods
fn pre(&mut self, t: T) -> T { ... }
fn post(&mut self, t: T) -> T { ... }
fn tree_apply(&mut self, t: T) -> T { ... }
}
Expand description
Given a tree-like structure T
,
we usually can specify a transformation T -> T
by providing a pre-order transformation pre : T -> T
and a post-order transformation post : T -> T
.
Specifically, the derived transformation apply : T -> T
first applies pre
,
then maps itself over the subtrees, and finally applies post
.
This allows us to obtain a global transformation acting recursively on all levels
by specifying simpler transformations at acts locally.
Required Methods§
Provided Methods§
fn pre(&mut self, t: T) -> T
fn post(&mut self, t: T) -> T
sourcefn tree_apply(&mut self, t: T) -> T
fn tree_apply(&mut self, t: T) -> T
The derived transformation based on pre
and post
.