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

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

Applies the given Folder 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).

Associated Types

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

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.

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 fold_ty method on the folder; this usually (in turn) invokes super_fold_ty to fold the individual parts.