pub trait Visitor {
type Break;
// Provided methods
fn enter(&mut self, this: &dyn Any) -> ControlFlow<Self::Break> { ... }
fn leave(&mut self, this: &dyn Any) -> ControlFlow<Self::Break> { ... }
}Expand description
A visitor that can be used to traverse a data structure.
Implement this trait to define custom logic that executes when
Traversable items are visited. You can implement enter and leave
methods to perform actions before and after processing a node, respectively.
For an example of implementing Visitor, see the FileCounter struct
in the crate-level documentation.
You can also use visitor to create a visitor from closures.
Required Associated Types§
Provided Methods§
Sourcefn enter(&mut self, this: &dyn Any) -> ControlFlow<Self::Break>
fn enter(&mut self, this: &dyn Any) -> ControlFlow<Self::Break>
Called when the visitor is entering a node.
Default implementation does nothing and continues traversal.
Sourcefn leave(&mut self, this: &dyn Any) -> ControlFlow<Self::Break>
fn leave(&mut self, this: &dyn Any) -> ControlFlow<Self::Break>
Called when the visitor is leaving a node.
Default implementation does nothing and continues traversal.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".