Crafting Interpreters in Rust: Parsing Unary Negation

In the last post, we implemented unary-not. In this one, we’ll implement the other unary operator: negation. As usual, we’ll start with a test: #[test] fn negation () { let parser = lox :: ExpressionParser :: new (); let expr = parser . parse ( "-42" ) . unwrap (); assert_eq! (expr, Expression :: Nil ); } Now — obviously — this isn’t going to pass, but it’ll prompt us through the steps to get it…