[][src]Trait chalk_solve::split::Split

pub trait Split<I: Interner>: RustIrDatabase<I> {
    fn split_projection<'p>(
        &self,
        projection: &'p ProjectionTy<I>
    ) -> (Arc<AssociatedTyDatum<I>>, &'p [GenericArg<I>], &'p [GenericArg<I>]) { ... }
fn trait_parameters_from_projection<'p>(
        &self,
        projection: &'p ProjectionTy<I>
    ) -> &'p [GenericArg<I>] { ... }
fn trait_ref_from_projection<'p>(
        &self,
        projection: &'p ProjectionTy<I>
    ) -> TraitRef<I> { ... }
fn split_associated_ty_value_parameters<'p, P>(
        &self,
        parameters: &'p [P],
        associated_ty_value: &AssociatedTyValue<I>
    ) -> (&'p [P], &'p [P]) { ... }
fn impl_parameters_and_projection_from_associated_ty_value<'p>(
        &self,
        parameters: &'p [GenericArg<I>],
        associated_ty_value: &AssociatedTyValue<I>
    ) -> (&'p [GenericArg<I>], ProjectionTy<I>) { ... } }

Methods for splitting up the projections for associated types from the surrounding context.

Provided methods

fn split_projection<'p>(
    &self,
    projection: &'p ProjectionTy<I>
) -> (Arc<AssociatedTyDatum<I>>, &'p [GenericArg<I>], &'p [GenericArg<I>])

Given a projection of an associated type, split the type parameters into those that come from the trait and those that come from the associated type itself. So e.g. if you have (Iterator::Item)<F>, this would return ([F], []), since Iterator::Item is not generic and hence doesn't have any type parameters itself.

fn trait_parameters_from_projection<'p>(
    &self,
    projection: &'p ProjectionTy<I>
) -> &'p [GenericArg<I>]

Given a projection <P0 as Trait<P1..Pn>>::Item<Pn..Pm>, returns the trait parameters [P0..Pn] (see split_projection).

fn trait_ref_from_projection<'p>(
    &self,
    projection: &'p ProjectionTy<I>
) -> TraitRef<I>

Given a projection <P0 as Trait<P1..Pn>>::Item<Pn..Pm>, returns the trait parameters [P0..Pn] (see split_projection).

fn split_associated_ty_value_parameters<'p, P>(
    &self,
    parameters: &'p [P],
    associated_ty_value: &AssociatedTyValue<I>
) -> (&'p [P], &'p [P])

Given the full set of parameters (or binders) for an associated type value (which appears in an impl), splits them into the substitutions for the impl and those for the associated type.

Example

This example is not tested
impl<T> Iterable for Vec<T> {
    type Iter<'a>;
}

in this example, the full set of parameters would be ['x, Y], where 'x is the value for 'a and Y is the value for T.

Returns

Returns the pair of:

  • the parameters for the impl ([Y], in our example)
  • the parameters for the associated type value (['a], in our example)

fn impl_parameters_and_projection_from_associated_ty_value<'p>(
    &self,
    parameters: &'p [GenericArg<I>],
    associated_ty_value: &AssociatedTyValue<I>
) -> (&'p [GenericArg<I>], ProjectionTy<I>)

Given the full set of parameters for an associated type value (which appears in an impl), returns the trait reference and projection that are being satisfied by that value.

Example

This example is not tested
impl<T> Iterable for Vec<T> {
    type Iter<'a>;
}

Here we expect the full set of parameters for Iter, which would be ['x, Y], where 'x is the value for 'a and Y is the value for T.

Returns the pair of:

  • the parameters that apply to the impl (Y, in our example)
  • the projection <Vec<Y> as Iterable>::Iter<'x>
Loading content...

Implementors

impl<DB: RustIrDatabase<I> + ?Sized, I: Interner> Split<I> for DB[src]

Loading content...