Reduce Boxing for Apply

This commit is contained in:
Richard Feldman 2019-05-22 22:04:30 -04:00
parent 9b13df8fd7
commit 55020f6d9f
3 changed files with 3 additions and 3 deletions

View file

@ -13,7 +13,7 @@ pub enum Expr {
// Functions // Functions
Func(String, Box<Expr>), Func(String, Box<Expr>),
Apply(Box<Expr>, Box<Expr>), Apply(Box<(Expr, Expr)>),
Operator(Box<Expr>, Operator, Box<Expr>), Operator(Box<Expr>, Operator, Box<Expr>),
Closure(Vec<Pattern>, Box<Expr>), Closure(Vec<Pattern>, Box<Expr>),

View file

@ -190,7 +190,7 @@ where I: Stream<Item = char, Position = IndentablePosition>,
match opt_expr2 { match opt_expr2 {
None => expr1, None => expr1,
Some(expr2) => { Some(expr2) => {
Expr::Apply(Box::new(expr1), Box::new(expr2)) Expr::Apply(Box::new((expr1, expr2)))
}, },
} }
) )

View file

@ -363,7 +363,7 @@ mod tests {
fn expect_parsed_apply<'a>(parse_str: &'a str, expr1: Expr, expr2: Expr) { fn expect_parsed_apply<'a>(parse_str: &'a str, expr1: Expr, expr2: Expr) {
assert_eq!( assert_eq!(
Ok((Apply(Box::new(expr1), Box::new(expr2)), "")), Ok((Apply(Box::new((expr1, expr2))), "")),
parse_standalone(parse_str) parse_standalone(parse_str)
); );
} }