Closed aDotInTheVoid closed 3 years ago
macro_rules! match_num_op {( $scrutinee:expr, $( $name:path => $op:tt ),* $(,)? ) => ( match $scrutinee { $( ($name, Int(l), Int(r)) => Int(l $op r), )* (o, l, r) => panic!("Unknown binop {:?}, {:?}, {:?}", l, o, r), } )} pub fn binop(l: Value, o: BinOp, r: Value) -> Value { use Value::*; match_num_op! { (o, l, r), BinOp::Plus => +, BinOp::Times => *, } }
We have binops, now we need tests