[][src]Trait chalk_ir::zip::Zipper

pub trait Zipper<'i, I: Interner> {
    fn zip_tys(&mut self, a: &Ty<I>, b: &Ty<I>) -> Fallible<()>;
fn zip_lifetimes(
        &mut self,
        a: &Lifetime<I>,
        b: &Lifetime<I>
    ) -> Fallible<()>;
fn zip_consts(&mut self, a: &Const<I>, b: &Const<I>) -> Fallible<()>;
fn zip_binders<T>(&mut self, a: &Binders<T>, b: &Binders<T>) -> Fallible<()>
    where
        T: HasInterner<Interner = I> + Zip<I> + Fold<I, I, Result = T>
;
fn interner(&self) -> &'i I; }

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

fn zip_tys(&mut self, a: &Ty<I>, b: &Ty<I>) -> Fallible<()>

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

fn zip_lifetimes(&mut self, a: &Lifetime<I>, b: &Lifetime<I>) -> Fallible<()>

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

fn zip_consts(&mut self, a: &Const<I>, b: &Const<I>) -> Fallible<()>

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

fn zip_binders<T>(&mut self, a: &Binders<T>, b: &Binders<T>) -> Fallible<()> where
    T: HasInterner<Interner = I> + Zip<I> + Fold<I, I, Result = T>, 

Zips two values appearing beneath binders.

fn interner(&self) -> &'i I

Retreives the interner from the underlying zipper object

Loading content...

Implementations on Foreign Types

impl<'f, 'i, Z, I> Zipper<'i, I> for &'f mut Z where
    I: Interner,
    Z: Zipper<'i, I>, 
[src]

Loading content...

Implementors

Loading content...