[][src]Trait chalk_ir::fold::Fold

pub trait Fold<I: Interner, TI: TargetInterner<I> = I>: Debug {
    type Result;
    fn fold_with<'i>(
        &self,
        folder: &mut dyn Folder<'i, I, TI>,
        outer_binder: DebruijnIndex
    ) -> Fallible<Self::Result>
    where
        I: 'i,
        TI: 'i
; }

Applies the given Folder to a value, producing a folded result of type Self::Result. The result is in the interner TI. The result type is typically the same as the source type (modulo interner), but in some cases we convert from borrowed to owned as well (e.g., the folder for &T will fold to a fresh T; well, actually T::Result).

Interners

The Fold trait has two type parameters, I and TI:

  • I is the "source interner" that we are folding from
  • TI is the "target interner" that we are folding into

Often, both are the same.

Associated Types

type Result

The type of value that will be produced once folding is done. Typically this is Self, unless Self contains borrowed values, in which case owned values are produced (for example, one can fold over a &T value where T: Fold, in which case you get back a T, not a &T).

Loading content...

Required methods

fn fold_with<'i>(
    &self,
    folder: &mut dyn Folder<'i, I, TI>,
    outer_binder: DebruijnIndex
) -> Fallible<Self::Result> where
    I: 'i,
    TI: 'i, 

Apply the given folder folder to self; binders is the number of binders that are in scope when beginning the folder. Typically binders starts as 0, but is adjusted when we encounter Binders<T> in the IR or other similar constructs.

Loading content...

Implementations on Foreign Types

impl<'a, T: Fold<I, TI>, I: Interner, TI: TargetInterner<I>> Fold<I, TI> for &'a T[src]

type Result = T::Result

impl<T: Fold<I, TI>, I: Interner, TI: TargetInterner<I>> Fold<I, TI> for Vec<T>[src]

type Result = Vec<T::Result>

impl<T: Fold<I, TI>, I: Interner, TI: TargetInterner<I>> Fold<I, TI> for Box<T>[src]

type Result = Box<T::Result>

impl<T: Fold<I, TI>, I: Interner, TI: TargetInterner<I>> Fold<I, TI> for Arc<T>[src]

type Result = Arc<T::Result>

impl<A: Fold<I, TI>, B: Fold<I, TI>, I: Interner, TI: TargetInterner<I>> Fold<I, TI> for (A, B)[src]

type Result = (A::Result, B::Result)

impl<A: Fold<I, TI>, B: Fold<I, TI>, C: Fold<I, TI>, I: Interner, TI: TargetInterner<I>> Fold<I, TI> for (A, B, C)[src]

type Result = (A::Result, B::Result, C::Result)

impl<A: Fold<I, TI>, B: Fold<I, TI>, C: Fold<I, TI>, D: Fold<I, TI>, I: Interner, TI: TargetInterner<I>> Fold<I, TI> for (A, B, C, D)[src]

type Result = (A::Result, B::Result, C::Result, D::Result)

impl<A: Fold<I, TI>, B: Fold<I, TI>, C: Fold<I, TI>, D: Fold<I, TI>, E: Fold<I, TI>, I: Interner, TI: TargetInterner<I>> Fold<I, TI> for (A, B, C, D, E)[src]

type Result = (A::Result, B::Result, C::Result, D::Result, E::Result)

impl<T: Fold<I, TI>, I: Interner, TI: TargetInterner<I>> Fold<I, TI> for Option<T>[src]

type Result = Option<T::Result>

impl<I: Interner, TI: TargetInterner<I>> Fold<I, TI> for bool[src]

type Result = Self

impl<I: Interner, TI: TargetInterner<I>> Fold<I, TI> for usize[src]

type Result = Self

impl<I: Interner, TI: TargetInterner<I>> Fold<I, TI> for ()[src]

type Result = Self

impl<I: Interner, TI: TargetInterner<I>> Fold<I, TI> for PhantomData<I>[src]

type Result = PhantomData<TI>

Loading content...

Implementors

impl<G: HasInterner, _I, _U, _TI> Fold<_I, _TI> for InEnvironment<G> where
    _I: Interner,
    G: HasInterner<Interner = _I>,
    G: Fold<_I, _TI, Result = _U>,
    _U: HasInterner<Interner = _TI>,
    _TI: TargetInterner<_I>, 
[src]

type Result = InEnvironment<_U>

impl<I, T, TI> Fold<I, TI> for Canonical<T> where
    I: Interner,
    T: HasInterner<Interner = I> + Fold<I, TI>,
    <T as Fold<I, TI>>::Result: HasInterner<Interner = TI>,
    TI: TargetInterner<I>, 
[src]

type Result = Canonical<T::Result>

impl<I: Interner, TI: TargetInterner<I>> Fold<I, TI> for ClausePriority[src]

type Result = Self

impl<I: Interner, TI: TargetInterner<I>> Fold<I, TI> for FloatTy[src]

type Result = Self

impl<I: Interner, TI: TargetInterner<I>> Fold<I, TI> for IntTy[src]

type Result = Self

impl<I: Interner, TI: TargetInterner<I>> Fold<I, TI> for Mutability[src]

type Result = Self

impl<I: Interner, TI: TargetInterner<I>> Fold<I, TI> for QuantifierKind[src]

type Result = Self

impl<I: Interner, TI: TargetInterner<I>> Fold<I, TI> for Scalar[src]

type Result = Self

impl<I: Interner, TI: TargetInterner<I>> Fold<I, TI> for UintTy[src]

type Result = Self

impl<I: Interner, TI: TargetInterner<I>> Fold<I, TI> for AdtId<I>[src]

type Result = AdtId<TI>

impl<I: Interner, TI: TargetInterner<I>> Fold<I, TI> for AssocTypeId<I>[src]

type Result = AssocTypeId<TI>

impl<I: Interner, TI: TargetInterner<I>> Fold<I, TI> for Const<I>[src]

"Folding" a const invokes the fold_const method on the folder; this usually (in turn) invokes super_fold_const to fold the individual parts.

type Result = Const<TI>

impl<I: Interner, TI: TargetInterner<I>> Fold<I, TI> for DebruijnIndex[src]

type Result = Self

impl<I: Interner, TI: TargetInterner<I>> Fold<I, TI> for Fn<I>[src]

type Result = Fn<TI>

impl<I: Interner, TI: TargetInterner<I>> Fold<I, TI> for FnDefId<I>[src]

type Result = FnDefId<TI>

impl<I: Interner, TI: TargetInterner<I>> Fold<I, TI> for GenericArg<I>[src]

type Result = GenericArg<TI>

impl<I: Interner, TI: TargetInterner<I>> Fold<I, TI> for Goal<I>[src]

Folding a goal invokes the fold_goal callback (which will, by default, invoke super-fold).

type Result = Goal<TI>

impl<I: Interner, TI: TargetInterner<I>> Fold<I, TI> for Goals<I>[src]

type Result = Goals<TI>

impl<I: Interner, TI: TargetInterner<I>> Fold<I, TI> for ImplId<I>[src]

type Result = ImplId<TI>

impl<I: Interner, TI: TargetInterner<I>> Fold<I, TI> for Lifetime<I>[src]

"Folding" a lifetime invokes the fold_lifetime method on the folder; this usually (in turn) invokes super_fold_lifetime to fold the individual parts.

type Result = Lifetime<TI>

impl<I: Interner, TI: TargetInterner<I>> Fold<I, TI> for OpaqueTyId<I>[src]

type Result = OpaqueTyId<TI>

impl<I: Interner, TI: TargetInterner<I>> Fold<I, TI> for PlaceholderIndex[src]

type Result = Self

impl<I: Interner, TI: TargetInterner<I>> Fold<I, TI> for ProgramClause<I>[src]

Folding a program clause invokes the fold_program_clause callback on the folder (which will, by default, invoke the super_fold_with method on the program clause).

type Result = ProgramClause<TI>

impl<I: Interner, TI: TargetInterner<I>> Fold<I, TI> for ProgramClauses<I>[src]

type Result = ProgramClauses<TI>

impl<I: Interner, TI: TargetInterner<I>> Fold<I, TI> for QuantifiedWhereClauses<I>[src]

type Result = QuantifiedWhereClauses<TI>

impl<I: Interner, TI: TargetInterner<I>> Fold<I, TI> for Substitution<I>[src]

type Result = Substitution<TI>

impl<I: Interner, TI: TargetInterner<I>> Fold<I, TI> for TraitId<I>[src]

type Result = TraitId<TI>

impl<I: Interner, TI: TargetInterner<I>> Fold<I, TI> for Ty<I>[src]

"Folding" a type invokes the fold_ty method on the folder; this usually (in turn) invokes super_fold_ty to fold the individual parts.

type Result = Ty<TI>

impl<I: Interner, TI: TargetInterner<I>> Fold<I, TI> for UniverseIndex[src]

type Result = Self

impl<I: Interner, _TI> Fold<I, _TI> for AliasTy<I> where
    _TI: TargetInterner<I>, 
[src]

type Result = AliasTy<_TI>

impl<I: Interner, _TI> Fold<I, _TI> for Constraint<I> where
    _TI: TargetInterner<I>, 
[src]

type Result = Constraint<_TI>

impl<I: Interner, _TI> Fold<I, _TI> for DomainGoal<I> where
    _TI: TargetInterner<I>, 
[src]

type Result = DomainGoal<_TI>

impl<I: Interner, _TI> Fold<I, _TI> for FromEnv<I> where
    _TI: TargetInterner<I>, 
[src]

type Result = FromEnv<_TI>

impl<I: Interner, _TI> Fold<I, _TI> for GenericArgData<I> where
    _TI: TargetInterner<I>, 
[src]

type Result = GenericArgData<_TI>

impl<I: Interner, _TI> Fold<I, _TI> for GoalData<I> where
    _TI: TargetInterner<I>, 
[src]

type Result = GoalData<_TI>

impl<I: Interner, _TI> Fold<I, _TI> for ProgramClauseData<I> where
    _TI: TargetInterner<I>, 
[src]

type Result = ProgramClauseData<_TI>

impl<I: Interner, _TI> Fold<I, _TI> for TypeName<I> where
    _TI: TargetInterner<I>, 
[src]

type Result = TypeName<_TI>

impl<I: Interner, _TI> Fold<I, _TI> for WellFormed<I> where
    _TI: TargetInterner<I>, 
[src]

type Result = WellFormed<_TI>

impl<I: Interner, _TI> Fold<I, _TI> for WhereClause<I> where
    _TI: TargetInterner<I>, 
[src]

type Result = WhereClause<_TI>

impl<I: Interner, _TI> Fold<I, _TI> for AliasEq<I> where
    _TI: TargetInterner<I>, 
[src]

type Result = AliasEq<_TI>

impl<I: Interner, _TI> Fold<I, _TI> for AnswerSubst<I> where
    _TI: TargetInterner<I>, 
[src]

type Result = AnswerSubst<_TI>

impl<I: Interner, _TI> Fold<I, _TI> for ApplicationTy<I> where
    _TI: TargetInterner<I>, 
[src]

type Result = ApplicationTy<_TI>

impl<I: Interner, _TI> Fold<I, _TI> for ConstrainedSubst<I> where
    _TI: TargetInterner<I>, 
[src]

type Result = ConstrainedSubst<_TI>

impl<I: Interner, _TI> Fold<I, _TI> for DynTy<I> where
    _TI: TargetInterner<I>, 
[src]

type Result = DynTy<_TI>

impl<I: Interner, _TI> Fold<I, _TI> for Environment<I> where
    _TI: TargetInterner<I>, 
[src]

type Result = Environment<_TI>

impl<I: Interner, _TI> Fold<I, _TI> for EqGoal<I> where
    _TI: TargetInterner<I>, 
[src]

type Result = EqGoal<_TI>

impl<I: Interner, _TI> Fold<I, _TI> for LifetimeOutlives<I> where
    _TI: TargetInterner<I>, 
[src]

type Result = LifetimeOutlives<_TI>

impl<I: Interner, _TI> Fold<I, _TI> for Normalize<I> where
    _TI: TargetInterner<I>, 
[src]

type Result = Normalize<_TI>

impl<I: Interner, _TI> Fold<I, _TI> for OpaqueTy<I> where
    _TI: TargetInterner<I>, 
[src]

type Result = OpaqueTy<_TI>

impl<I: Interner, _TI> Fold<I, _TI> for ProgramClauseImplication<I> where
    _TI: TargetInterner<I>, 
[src]

type Result = ProgramClauseImplication<_TI>

impl<I: Interner, _TI> Fold<I, _TI> for ProjectionTy<I> where
    _TI: TargetInterner<I>, 
[src]

type Result = ProjectionTy<_TI>

impl<I: Interner, _TI> Fold<I, _TI> for TraitRef<I> where
    _TI: TargetInterner<I>, 
[src]

type Result = TraitRef<_TI>

impl<T, I: Interner, TI: TargetInterner<I>> Fold<I, TI> for Binders<T> where
    T: HasInterner<Interner = I> + Fold<I, TI>,
    <T as Fold<I, TI>>::Result: HasInterner<Interner = TI>,
    I: Interner
[src]

type Result = Binders<T::Result>

Loading content...