[−][src]Trait ra_ap_hir_ty::TypeWalk
This allows walking structures that contain types to do something with those
types, similar to Chalk's Fold
trait.
Required methods
fn walk(&self, f: &mut impl FnMut(&Ty))
fn walk_mut_binders(
&mut self,
f: &mut impl FnMut(&mut Ty, DebruijnIndex),
binders: DebruijnIndex
)
&mut self,
f: &mut impl FnMut(&mut Ty, DebruijnIndex),
binders: DebruijnIndex
)
Walk the type, counting entered binders.
Ty::Bound
variables use DeBruijn indexing, which means that 0 refers
to the innermost binder, 1 to the next, etc.. So when we want to
substitute a certain bound variable, we can't just walk the whole type
and blindly replace each instance of a certain index; when we 'enter'
things that introduce new bound variables, we have to keep track of
that. Currently, the only thing that introduces bound variables on our
side are Ty::Dyn
and Ty::Opaque
, which each introduce a bound
variable for the self type.
Provided methods
fn walk_mut(&mut self, f: &mut impl FnMut(&mut Ty))
fn fold_binders(
self,
f: &mut impl FnMut(Ty, DebruijnIndex) -> Ty,
binders: DebruijnIndex
) -> Self where
Self: Sized,
self,
f: &mut impl FnMut(Ty, DebruijnIndex) -> Ty,
binders: DebruijnIndex
) -> Self where
Self: Sized,
fn fold(self, f: &mut impl FnMut(Ty) -> Ty) -> Self where
Self: Sized,
Self: Sized,
fn subst_bound_vars(self, substs: &Substs) -> Self where
Self: Sized,
Self: Sized,
Substitutes Ty::Bound
vars with the given substitution.
fn subst_bound_vars_at_depth(
self,
substs: &Substs,
depth: DebruijnIndex
) -> Self where
Self: Sized,
self,
substs: &Substs,
depth: DebruijnIndex
) -> Self where
Self: Sized,
Substitutes Ty::Bound
vars with the given substitution.
fn shift_bound_vars(self, n: DebruijnIndex) -> Self where
Self: Sized,
Self: Sized,
Shifts up debruijn indices of Ty::Bound
vars by n
.
Implementations on Foreign Types
impl<T: TypeWalk> TypeWalk for Vec<T>
[src]
fn walk(&self, f: &mut impl FnMut(&Ty))
[src]
fn walk_mut_binders(
&mut self,
f: &mut impl FnMut(&mut Ty, DebruijnIndex),
binders: DebruijnIndex
)
[src]
&mut self,
f: &mut impl FnMut(&mut Ty, DebruijnIndex),
binders: DebruijnIndex
)
Implementors
impl TypeWalk for GenericPredicate
[src]
fn walk(&self, f: &mut impl FnMut(&Ty))
[src]
fn walk_mut_binders(
&mut self,
f: &mut impl FnMut(&mut Ty, DebruijnIndex),
binders: DebruijnIndex
)
[src]
&mut self,
f: &mut impl FnMut(&mut Ty, DebruijnIndex),
binders: DebruijnIndex
)
impl TypeWalk for Ty
[src]
fn walk(&self, f: &mut impl FnMut(&Ty))
[src]
fn walk_mut_binders(
&mut self,
f: &mut impl FnMut(&mut Ty, DebruijnIndex),
binders: DebruijnIndex
)
[src]
&mut self,
f: &mut impl FnMut(&mut Ty, DebruijnIndex),
binders: DebruijnIndex
)
impl TypeWalk for FnSig
[src]
fn walk(&self, f: &mut impl FnMut(&Ty))
[src]
fn walk_mut_binders(
&mut self,
f: &mut impl FnMut(&mut Ty, DebruijnIndex),
binders: DebruijnIndex
)
[src]
&mut self,
f: &mut impl FnMut(&mut Ty, DebruijnIndex),
binders: DebruijnIndex
)
impl TypeWalk for ProjectionTy
[src]
fn walk(&self, f: &mut impl FnMut(&Ty))
[src]
fn walk_mut_binders(
&mut self,
f: &mut impl FnMut(&mut Ty, DebruijnIndex),
binders: DebruijnIndex
)
[src]
&mut self,
f: &mut impl FnMut(&mut Ty, DebruijnIndex),
binders: DebruijnIndex
)
impl TypeWalk for Substs
[src]
fn walk(&self, f: &mut impl FnMut(&Ty))
[src]
fn walk_mut_binders(
&mut self,
f: &mut impl FnMut(&mut Ty, DebruijnIndex),
binders: DebruijnIndex
)
[src]
&mut self,
f: &mut impl FnMut(&mut Ty, DebruijnIndex),
binders: DebruijnIndex
)
impl TypeWalk for TraitRef
[src]
fn walk(&self, f: &mut impl FnMut(&Ty))
[src]
fn walk_mut_binders(
&mut self,
f: &mut impl FnMut(&mut Ty, DebruijnIndex),
binders: DebruijnIndex
)
[src]
&mut self,
f: &mut impl FnMut(&mut Ty, DebruijnIndex),
binders: DebruijnIndex
)
impl TypeWalk for ProjectionPredicate
[src]
fn walk(&self, f: &mut impl FnMut(&Ty))
[src]
fn walk_mut_binders(
&mut self,
f: &mut impl FnMut(&mut Ty, DebruijnIndex),
binders: DebruijnIndex
)
[src]
&mut self,
f: &mut impl FnMut(&mut Ty, DebruijnIndex),
binders: DebruijnIndex
)
impl<T: TypeWalk> TypeWalk for Binders<T>
[src]
fn walk(&self, f: &mut impl FnMut(&Ty))
[src]
fn walk_mut_binders(
&mut self,
f: &mut impl FnMut(&mut Ty, DebruijnIndex),
binders: DebruijnIndex
)
[src]
&mut self,
f: &mut impl FnMut(&mut Ty, DebruijnIndex),
binders: DebruijnIndex
)