Trait ra_ap_hir_ty::TypeWalk [−][src]
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))
[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
)
Walk the type, counting entered binders.
TyKind::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 TyKind::Dyn
and TyKind::Opaque
, which each introduce a bound
variable for the self type.
Provided methods
fn walk_mut(&mut self, f: &mut impl FnMut(&mut Ty))
[src]
fn fold_binders(
self,
f: &mut impl FnMut(Ty, DebruijnIndex) -> Ty,
binders: DebruijnIndex
) -> Self where
Self: Sized,
[src]
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,
[src]
Self: Sized,
fn subst_bound_vars(self, substs: &Substitution) -> Self where
Self: Sized,
[src]
Self: Sized,
Substitutes TyKind::Bound
vars with the given substitution.
fn subst_bound_vars_at_depth(
self,
substs: &Substitution,
depth: DebruijnIndex
) -> Self where
Self: Sized,
[src]
self,
substs: &Substitution,
depth: DebruijnIndex
) -> Self where
Self: Sized,
Substitutes TyKind::Bound
vars with the given substitution.
fn shift_bound_vars(self, n: DebruijnIndex) -> Self where
Self: Sized,
[src]
Self: Sized,
Shifts up debruijn indices of TyKind::Bound
vars by n
.
fn shift_bound_vars_out(self, n: DebruijnIndex) -> Self where
Self: Sized + Debug,
[src]
Self: Sized + Debug,
Shifts debruijn indices of TyKind::Bound
vars out (down) 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 AliasTy
[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 WhereClause
[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 AliasEq
[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 CallableSig
[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 GenericArg
[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 OpaqueTy
[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 Substitution
[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 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<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
)