pub trait Zipper<I: Interner> {
    fn zip_tys(&mut self, variance: Variance, a: &Ty<I>, b: &Ty<I>) -> Fallible<()>;
    fn zip_lifetimes(
        &mut self,
        variance: Variance,
        a: &Lifetime<I>,
        b: &Lifetime<I>
    ) -> Fallible<()>; fn zip_consts(
        &mut self,
        variance: Variance,
        a: &Const<I>,
        b: &Const<I>
    ) -> Fallible<()>; fn zip_binders<T>(
        &mut self,
        variance: Variance,
        a: &Binders<T>,
        b: &Binders<T>
    ) -> Fallible<()>
    where
        T: Clone + HasInterner<Interner = I> + Zip<I> + TypeFoldable<I>
; fn interner(&self) -> I; fn unification_database(&self) -> &dyn UnificationDatabase<I>; fn zip_substs(
        &mut self,
        ambient: Variance,
        variances: Option<Variances<I>>,
        a: &[GenericArg<I>],
        b: &[GenericArg<I>]
    ) -> Fallible<()>
    where
        Self: Sized
, { ... } }
Expand description

When we zip types, we basically traverse the structure, ensuring that it matches. When we come to types/lifetimes, we invoke the callback methods in the zipper to match them up. Primarily used during unification or similar operations.

So e.g. if you had A: Eq<B> zipped with X: Eq<Y>, then the zipper would get two callbacks, one pairing A and X, and the other pairing B and Y.

For things other than types/lifetimes, the zip impls will guarantee equality. So e.g. if you have A: Eq<B> zipped with X: Ord<Y>, you would wind up with an error, no matter what zipper you are using. This is because the traits Eq and Ord are represented by two distinct ItemId values, and the impl for ItemId requires that all ItemId in the two zipped values match up.

Required Methods

Indicates that the two types a and b were found in matching spots.

Indicates that the two lifetimes a and b were found in matching spots.

Indicates that the two consts a and b were found in matching spots.

Zips two values appearing beneath binders.

Retrieves the interner from the underlying zipper object

Retrieves the UnificationDatabase from the underlying zipper object

Provided Methods

Zips two substs

Implementations on Foreign Types

Implementors