Skip to main content

types_match

Function types_match 

Source
pub fn types_match(pattern: &Ty, target: &Ty) -> Option<Subst>
Expand description

Match a pattern type against a target type, returning a substitution.

Performs one-way pattern matching where type variables in the pattern are bound to concrete types in the target. This enables polymorphic instance matching like instance Eq a => Eq [a] to match Eq [Int] with {a -> Int}.

§Arguments

  • pattern - The instance type pattern (may contain type variables)
  • target - The concrete type to match against

§Returns

Some(subst) if the match succeeds, where subst maps type variables to types. None if the types cannot be matched.