pub trait Visit {
// Provided methods
fn visit_tree(&mut self, root: &Node) { ... }
fn visit_node(&mut self, node: &Node, ancestors: &[&Node]) { ... }
fn visit_leaf(
&mut self,
_measures: &[Measure],
_intensity: Option<&Intensity>,
_ancestors: &[&Node],
) { ... }
fn visit_exercise(
&mut self,
_name: Option<&str>,
_measures: &[Measure],
_intensity: Option<&Intensity>,
_ancestors: &[&Node],
) { ... }
fn visit_block(&mut self, _mode: &ExecutionMode, _ancestors: &[&Node]) { ... }
}Expand description
Immutable tree visitor with ancestor path context.
ancestors is a slice of parent nodes from root to immediate parent.
Empty at the root node, grows as the walk descends.
Usage: struct MyVisitor; impl Visit for MyVisitor { fn visit_leaf(&mut self, measures: &Measure, _: Option<&Intensity>, ancestors: &[&Node]) { // ancestors[0] is root, ancestors.last() is the parent Exercise/Block } } let mut v = MyVisitor; v.visit_tree(&workout.root);
Provided Methods§
Sourcefn visit_tree(&mut self, root: &Node)
fn visit_tree(&mut self, root: &Node)
Convenience entry point. Calls visit_node with empty ancestors.