Trait rustc_type_ir::visit::TypeVisitable
source · pub trait TypeVisitable<I: Interner>: Debug + Clone {
// Required method
fn visit_with<V: TypeVisitor<I>>(
&self,
visitor: &mut V
) -> ControlFlow<V::BreakTy>;
}
Expand description
This trait is implemented for every type that can be visited, providing the skeleton of the traversal.
To implement this conveniently, use the derive macro located in
rustc_macros
.
Required Methods§
sourcefn visit_with<V: TypeVisitor<I>>(
&self,
visitor: &mut V
) -> ControlFlow<V::BreakTy>
fn visit_with<V: TypeVisitor<I>>( &self, visitor: &mut V ) -> ControlFlow<V::BreakTy>
The entry point for visiting. To visit a value t
with a visitor v
call: t.visit_with(v)
.
For most types, this just traverses the value, calling visit_with
on
each field/element.
For types of interest (such as Ty
), the implementation of this method
that calls a visitor method specifically for that type (such as
V::visit_ty
). This is where control transfers from TypeVisitable
to
TypeVisitor
.