pub trait TypeFoldable<I: Interner>: Debug + Sized {
    fn try_fold_with<E>(
        self,
        folder: &mut dyn FallibleTypeFolder<I, Error = E>,
        outer_binder: DebruijnIndex
    ) -> Result<Self, E>; fn fold_with(
        self,
        folder: &mut dyn TypeFolder<I>,
        outer_binder: DebruijnIndex
    ) -> Self { ... } }
Expand description

Applies the given TypeFolder to a value, producing a folded result of type Self::Result. The result type is typically the same as the source type, 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).

Required Methods

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.

Provided Methods

A convenient alternative to try_fold_with for use with infallible folders. Do not override this method, to ensure coherence with try_fold_with.

Implementations on Foreign Types

Implementors

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

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

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

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).

“Folding” a type invokes the try_fold_ty method on the folder; this usually (in turn) invokes try_super_fold_ty to fold the individual parts.