Trait ra_ap_hir_ty::TypeWalk[][src]

pub trait TypeWalk {
    fn walk(&self, f: &mut impl FnMut(&Ty));
fn walk_mut_binders(
        &mut self,
        f: &mut impl FnMut(&mut Ty, DebruijnIndex),
        binders: DebruijnIndex
    ); 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
, { ... }
fn fold(self, f: &mut impl FnMut(Ty) -> Ty) -> Self
    where
        Self: Sized
, { ... }
fn subst_bound_vars(self, substs: &Substitution) -> Self
    where
        Self: Sized
, { ... }
fn subst_bound_vars_at_depth(
        self,
        substs: &Substitution,
        depth: DebruijnIndex
    ) -> Self
    where
        Self: Sized
, { ... }
fn shift_bound_vars(self, n: DebruijnIndex) -> Self
    where
        Self: Sized
, { ... }
fn shift_bound_vars_out(self, n: DebruijnIndex) -> Self
    where
        Self: Sized + Debug
, { ... } }

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]

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.

Loading content...

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]

fn fold(self, f: &mut impl FnMut(Ty) -> Ty) -> Self where
    Self: Sized
[src]

fn subst_bound_vars(self, substs: &Substitution) -> Self where
    Self: Sized
[src]

Substitutes TyKind::Bound vars with the given substitution.

fn subst_bound_vars_at_depth(
    self,
    substs: &Substitution,
    depth: DebruijnIndex
) -> Self where
    Self: Sized
[src]

Substitutes TyKind::Bound vars with the given substitution.

fn shift_bound_vars(self, n: DebruijnIndex) -> Self where
    Self: Sized
[src]

Shifts up debruijn indices of TyKind::Bound vars by n.

fn shift_bound_vars_out(self, n: DebruijnIndex) -> Self where
    Self: Sized + Debug
[src]

Shifts debruijn indices of TyKind::Bound vars out (down) by n.

Loading content...

Implementations on Foreign Types

impl<T: TypeWalk> TypeWalk for Vec<T>[src]

Loading content...

Implementors

impl TypeWalk for AliasTy[src]

impl TypeWalk for WhereClause[src]

impl TypeWalk for AliasEq[src]

impl TypeWalk for CallableSig[src]

impl TypeWalk for GenericArg[src]

impl TypeWalk for OpaqueTy[src]

impl TypeWalk for ProjectionTy[src]

impl TypeWalk for Substitution[src]

impl TypeWalk for TraitRef[src]

impl TypeWalk for Ty[src]

impl<T: TypeWalk> TypeWalk for Binders<T>[src]

Loading content...