pub trait VisitChildren<T> {
// Required methods
fn children<'a>(&'a self) -> impl DoubleEndedIterator<Item = &'a T>
where T: 'a;
fn children_mut<'a>(
&'a mut self,
) -> impl DoubleEndedIterator<Item = &'a mut T>
where T: 'a;
// Provided 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> { ... }
fn try_visit_mut_children<F, E>(&mut self, f: F) -> Result<(), E>
where F: FnMut(&mut T) -> Result<(), E> { ... }
}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 children<'a>(&'a self) -> impl DoubleEndedIterator<Item = &'a T>where
T: 'a,
fn children<'a>(&'a self) -> impl DoubleEndedIterator<Item = &'a T>where
T: 'a,
The T-typed children of this element.
Sourcefn children_mut<'a>(&'a mut self) -> impl DoubleEndedIterator<Item = &'a mut T>where
T: 'a,
fn children_mut<'a>(&'a mut self) -> impl DoubleEndedIterator<Item = &'a mut T>where
T: 'a,
The &mut T-typed children of this element.
It is critical for the safety of mutable post-order traversals that this function be written using safe code.
Provided 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.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".