pub trait Visit<T> {
// Required methods
fn visit<'a>(&'a self) -> impl Iterator<Item = &'a T>
where T: 'a;
fn visit_mut<'a>(&'a mut self) -> impl Iterator<Item = &'a mut T>
where T: 'a;
// Provided methods
fn visit_rec<'a, F>(&'a self, f: &mut F)
where T: Visit<T> + 'a,
F: FnMut(&T) { ... }
fn visit_rec_mut<'a, F>(&'a mut self, f: &mut F)
where T: Visit<T> + 'a,
F: FnMut(&mut T) { ... }
}Required Methods§
Sourcefn visit<'a>(&'a self) -> impl Iterator<Item = &'a T>where
T: 'a,
fn visit<'a>(&'a self) -> impl Iterator<Item = &'a T>where
T: 'a,
Visit each child node of type T in the subtree of Self.
Implementations of Visit do not recurse past T, meaning that if you really want
to visit all children of type T you would have to call <T as Visit<T>>::visit on
each visited T. Alternatively, use Self::visit_rec which solves this
exact problem.
Sourcefn visit_mut<'a>(&'a mut self) -> impl Iterator<Item = &'a mut T>where
T: 'a,
fn visit_mut<'a>(&'a mut self) -> impl Iterator<Item = &'a mut T>where
T: 'a,
Mutable version of Self::visit.
Provided Methods§
Sourcefn visit_rec<'a, F>(&'a self, f: &mut F)
fn visit_rec<'a, F>(&'a self, f: &mut F)
Visit each child node of type T in the subtree of Self, recursively in depth-first order.
Due to Rust’s aliasing model, you can’t iterate mutably on a node and its children. This function allows visiting recursively by passing a closure instead.
Sourcefn visit_rec_mut<'a, F>(&'a mut self, f: &mut F)
fn visit_rec_mut<'a, F>(&'a mut self, f: &mut F)
Mutable version of Self::visit_rec.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".