pub trait BodyVisitable: Any {
// Required methods
fn drive_body<V: VisitBody>(&self, v: &mut V) -> ControlFlow<V::Break>;
fn drive_body_mut<V: VisitBodyMut>(
&mut self,
v: &mut V,
) -> ControlFlow<V::Break>;
// Provided methods
fn dyn_visit_in_body<T: BodyVisitable>(&self, f: impl FnMut(&T)) { ... }
fn dyn_visit_in_body_mut<T: BodyVisitable>(&mut self, f: impl FnMut(&mut T)) { ... }
}
Expand description
A smaller visitor group just for function bodies. This explores statements, places and operands, but does not recurse into types.
This defines three traits:
BodyVisitable
is a trait implemented by all the types listed below; it has adrive_body[_mut]
method that takes aVisitBody[Mut]
visitor and calls its methods on all the relevant subvalues ofself
encountered.VisitBody[Mut]
is a (pair of) visitor trait(s) that can be implemented by visitors. To define a visitor, implementVisitBody[Mut]
and override the methods you need.
Morally this represents the predicate for<V: VisitBody[Mut]> Self: Drive[Mut]<BodyVisitableWrapper<V>>
Required Methods§
sourcefn drive_body<V: VisitBody>(&self, v: &mut V) -> ControlFlow<V::Break>
fn drive_body<V: VisitBody>(&self, v: &mut V) -> ControlFlow<V::Break>
Recursively visit this type with the provided visitor. This calls the visitor’s visit_$any
method if it exists, otherwise visit_inner
.
sourcefn drive_body_mut<V: VisitBodyMut>(
&mut self,
v: &mut V,
) -> ControlFlow<V::Break>
fn drive_body_mut<V: VisitBodyMut>( &mut self, v: &mut V, ) -> ControlFlow<V::Break>
Recursively visit this type with the provided visitor. This calls the visitor’s visit_$any
method if it exists, otherwise visit_inner
.
Provided Methods§
sourcefn dyn_visit_in_body<T: BodyVisitable>(&self, f: impl FnMut(&T))
fn dyn_visit_in_body<T: BodyVisitable>(&self, f: impl FnMut(&T))
Visit all occurrences of that type inside self
, in pre-order traversal.
sourcefn dyn_visit_in_body_mut<T: BodyVisitable>(&mut self, f: impl FnMut(&mut T))
fn dyn_visit_in_body_mut<T: BodyVisitable>(&mut self, f: impl FnMut(&mut T))
Visit all occurrences of that type inside self
, in pre-order traversal.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.