pub fn substitute(&mut self, substs: &Substitutions) {
        match *Rc::make_mut(&mut self.inner) {
            Expr::Ann(_, ref mut expr, ref mut ty) => {
                expr.substitute(substs);
                ty.substitute(substs);
            }
            Expr::Var(_, Var::Free(ref name)) => match substs.get(name) {
                None => {}
                Some(ty) => panic!("Expected to substitute an expression, but found {:?}", ty),
            },
            Expr::Var(_, Var::Bound(_)) | Expr::Const(_, _) => {}
            Expr::Lam(_, ref mut args, ref mut body_expr) => {
                for arg in args {
                    arg.inner.substitute(substs);
                }

                body_expr.substitute(substs);
            }
            Expr::App(_, ref mut fn_expr, ref mut arg_exprs) => {
                fn_expr.substitute(substs);

                for arg_expr in arg_exprs {
                    arg_expr.substitute(substs);
                }
            }

            Expr::Intro(_, _, ref mut expr) => {
                expr.substitute(substs);
            }
            Expr::Array(_, ref mut elems) => for elem in elems {
                elem.substitute(substs);
            },

            Expr::Unop(_, _, ref mut expr) | Expr::Proj(_, ref mut expr, _) => {
                expr.substitute(substs);
            }
            Expr::Binop(_, _, ref mut lhs_expr, ref mut rhs_expr) => {
                lhs_expr.substitute(substs);
                rhs_expr.substitute(substs);
            }
            Expr::Struct(ref mut fields) => for field in fields {
                field.value.substitute(substs);
            },
            Expr::Subscript(_, ref mut array_expr, ref mut index_expr) => {
                array_expr.substitute(substs);
                index_expr.substitute(substs);
            }
            Expr::Cast(_, ref mut src_expr, ref mut dst_ty) => {
                src_expr.substitute(substs);
                dst_ty.substitute(substs);
            }
        }
    }
/// Replace occurrences of the free variables that exist as keys on
/// `substs` with their corresponding types.
Replace occurrences of the free variables that exist as keys on
`substs` with their corresponding types.
Replace occurrences of the free variables that exist as keys on ` substs ` with their corresponding types .
pub fn substitute(&mut self, substs: &Substitutions) {
        match *Rc::make_mut(&mut self.inner) {
            Expr::Ann(_, ref mut expr, ref mut ty) => {
                expr.substitute(substs);
                ty.substitute(substs);
            }
            Expr::Var(_, Var::Free(ref name)) => match substs.get(name) {
                None => {}
                Some(ty) => panic!("Expected to substitute an expression, but found {:?}", ty),
            },
            Expr::Var(_, Var::Bound(_)) | Expr::Const(_, _) => {}
            Expr::Lam(_, ref mut args, ref mut body_expr) => {
                for arg in args {
                    arg.inner.substitute(substs);
                }
                body_expr.substitute(substs);
            }
            Expr::App(_, ref mut fn_expr, ref mut arg_exprs) => {
                fn_expr.substitute(substs);
                for arg_expr in arg_exprs {
                    arg_expr.substitute(substs);
                }
            }
            Expr::Intro(_, _, ref mut expr) => {
                expr.substitute(substs);
            }
            Expr::Array(_, ref mut elems) => for elem in elems {
                elem.substitute(substs);
            },
            Expr::Unop(_, _, ref mut expr) | Expr::Proj(_, ref mut expr, _) => {
                expr.substitute(substs);
            }
            Expr::Binop(_, _, ref mut lhs_expr, ref mut rhs_expr) => {
                lhs_expr.substitute(substs);
                rhs_expr.substitute(substs);
            }
            Expr::Struct(ref mut fields) => for field in fields {
                field.value.substitute(substs);
            },
            Expr::Subscript(_, ref mut array_expr, ref mut index_expr) => {
                array_expr.substitute(substs);
                index_expr.substitute(substs);
            }
            Expr::Cast(_, ref mut src_expr, ref mut dst_ty) => {
                src_expr.substitute(substs);
                dst_ty.substitute(substs);
            }
        }
    }
pub fn substitute ( & mut self , substs : & Substitutions ) { match * Rc :: make_mut ( & mut self . inner ) { Expr :: Ann ( _ , ref mut expr , ref mut ty ) => { expr . substitute ( substs ) ; ty . substitute ( substs ) ; } Expr :: Var ( _ , Var :: Free ( ref name ) ) => match substs . get ( name ) { None => { } Some ( ty ) => panic ! ( " " ty ) , } , Expr :: Var ( _ , Var :: Bound ( _ ) ) | Expr :: Const ( _ , _ ) => { } Expr :: Lam ( _ , ref mut args , ref mut body_expr ) => { for arg in args { arg . inner . substitute ( substs ) ; } body_expr . substitute ( substs ) ; } Expr :: App ( _ , ref mut fn_expr , ref mut arg_exprs ) => { fn_expr . substitute ( substs ) ; for arg_expr in arg_exprs { arg_expr . substitute ( substs ) ; } } Expr :: Intro ( _ , _ , ref mut expr ) => { expr . substitute ( substs ) ; } Expr :: Array ( _ , ref mut elems ) => for elem in elems { elem . substitute ( substs ) ; } , Expr :: Unop ( _ , _ , ref mut expr ) | Expr :: Proj ( _ , ref mut expr , _ ) => { expr . substitute ( substs ) ; } Expr :: Binop ( _ , _ , ref mut lhs_expr , ref mut rhs_expr ) => { lhs_expr . substitute ( substs ) ; rhs_expr . substitute ( substs ) ; } Expr :: Struct ( ref mut fields ) => for field in fields { field . value . substitute ( substs ) ; } , Expr :: Subscript ( _ , ref mut array_expr , ref mut index_expr ) => { array_expr . substitute ( substs ) ; index_expr . substitute ( substs ) ; } Expr :: Cast ( _ , ref mut src_expr , ref mut dst_ty ) => { src_expr . substitute ( substs ) ; dst_ty . substitute ( substs ) ; } } }
Replace occurrences of the free variables that exist as keys on
`substs` with their corresponding types.
Replace occurrences of the free variables that exist as keys on ` substs ` with their corresponding types .
&mut self
substs
&Substitutions
&mut self
substs
&Substitutions