pub trait VisitChildren<T> {
// Required methods
fn visit_children<F>(&self, f: F)
where F: FnMut(&T);
fn visit_mut_children<F>(&mut self, f: F)
where F: FnMut(&mut T);
fn try_visit_children<F, E>(&self, f: F) -> Result<(), E>
where F: FnMut(&T) -> Result<(), E>,
E: From<RecursionLimitError>;
fn try_visit_mut_children<F, E>(&mut self, f: F) -> Result<(), E>
where F: FnMut(&mut T) -> Result<(), E>,
E: From<RecursionLimitError>;
}Expand description
A trait for types that can visit their direct children of type T.
Implementing VisitChildren<Self> automatically also implements
the Visit trait, which enables recursive traversal.
Note that care needs to be taken when implementing this trait for
mutually recursive types (such as a type A where A has children
of type B and vice versa). More specifically, at the moment it is
not possible to implement versions of VisitChildren<A> for A such
that A considers as its children all A-nodes occurring at leaf
positions of B-children and vice versa for VisitChildren<B> for B.
Doing this will result in recursion limit violations as indicated
in the accompanying test_recursive_types_b test.
Required Methods§
Sourcefn visit_children<F>(&self, f: F)
fn visit_children<F>(&self, f: F)
Apply an infallible immutable function f to each direct child.
Sourcefn visit_mut_children<F>(&mut self, f: F)
fn visit_mut_children<F>(&mut self, f: F)
Apply an infallible mutable function f to each direct child.
Sourcefn try_visit_children<F, E>(&self, f: F) -> Result<(), E>
fn try_visit_children<F, E>(&self, f: F) -> Result<(), E>
Apply a fallible immutable function f to each direct child.
For mutually recursive implementations (say consisting of two
types A and B), recursing through B in order to find all
A-children of a node of type A might cause lead to a
RecursionLimitError, hence the bound on E.
Sourcefn try_visit_mut_children<F, E>(&mut self, f: F) -> Result<(), E>
fn try_visit_mut_children<F, E>(&mut self, f: F) -> Result<(), E>
Apply a fallible mutable function f to each direct child.
For mutually recursive implementations (say consisting of two
types A and B), recursing through B in order to find all
A-children of a node of type A might cause lead to a
RecursionLimitError, hence the bound on E.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".