1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
use std::ops::Neg; use ::*; impl Neg for Expr { type Output = Expr; fn neg(self) -> Expr { self * -1 } } #[test] fn expr() { let negated = -s!(x); assert_eq!(format!("{:?}", negated), "Mul(Symbol(\"x\"), Num(-1.0))"); }