/// Apply a single type substitution.
Apply a single type substitution.
Apply a single type substitution .
fn apply_one(self, var: &Variable, ttype: &Type) -> Type {
        match self {
            Type::Unit | Type::Bool | Type::Int => self,
            Type::Func(ty1, ty2) => Type::Func(
                Box::new(ty1.apply_one(var, ttype)),
                Box::new(ty2.apply_one(var, ttype)),
            ),
            Type::Tuple(fst, snd, rest) => Type::Tuple(
                Box::new(fst.apply_one(var, ttype)),
                Box::new(snd.apply_one(var, ttype)),
                rest.into_iter().map(|ty| ty.apply_one(var, ttype)).collect(),
            ),
            Type::Var(v) => if *var == v {
                ttype.clone()
            } else {
                Type::Var(v)
            },
        }
    }
fn apply_one ( self , var : & Variable , ttype : & Type ) -> Type { match self { Type :: Unit | Type :: Bool | Type :: Int => self , Type :: Func ( ty1 , ty2 ) => Type :: Func ( Box :: new ( ty1 . apply_one ( var , ttype ) ) , Box :: new ( ty2 . apply_one ( var , ttype ) ) , ) , Type :: Tuple ( fst , snd , rest ) => Type :: Tuple ( Box :: new ( fst . apply_one ( var , ttype ) ) , Box :: new ( snd . apply_one ( var , ttype ) ) , rest . into_iter ( ) . map ( | ty | ty . apply_one ( var , ttype ) ) . collect ( ) , ) , Type :: Var ( v ) => if * var == v { ttype . clone ( ) } else { Type :: Var ( v ) } , } }
Apply a single type substitution.
Apply a single type substitution .
self
var
&Variable
ttype
&Type