pub struct TypeInstantiationDerivation {}
Expand description

A helper to derive the set of instantiations for type parameters

Implementations§

source§

impl TypeInstantiationDerivation

source

pub fn progressive_instantiation<'a, I>( lhs_types: I, rhs_types: I, treat_lhs_type_param_as_var: bool, treat_rhs_type_param_as_var: bool, refine_lhs: bool, refine_rhs: bool, params_arity: usize, target_lhs: bool, mark_irrelevant_param_as_error: bool ) -> BTreeSet<Vec<Type>>where I: Iterator<Item = &'a Type> + Clone,

Find the set of valid instantiation combinations for all the type parameters.

The algorithm is progressive. For a list of parameters with arity params_arity = N, it

  • first finds all possible instantiation for parameter at index 0 (inst_param_0) and,’
  • for each instantiation in inst_param_0,
    • refines LHS or RHS types and
    • finds all possible instantiations for parameter at index 1 (inst_param_1)
    • for each instantiation in inst_param_1,
      • refines LHS or RHS types and
      • finds all possible instantiations for parameter at index 2 (inst_param_2)
      • for each instantiation in inst_param_2,
        • …… The process continues until all type parameters are analyzed (i.e., reaching the type parameter at index N).

If refine_lhs is True, refine the lhs_types after each round; same for refine_rhs.

If target_lhs is True, find instantiations for the type parameters in the lhs_types, otherwise, target the rhs_types.

If mark_irrelevant_param_as_error is True, type parameters that do not have any valid instantiation will be marked as Type::Error. Otherwise, leave the type parameter as it is.

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

const: unstable · source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

§

fn vzip(self) -> V