use std::ops; use super::{Expr, Scalar, Unknown}; impl From for Expr { fn from(c: Scalar) -> Expr { Expr::Const(c) } } impl From for Expr { fn from(u: Unknown) -> Expr { Expr::Unkn(u) } } impl ops::Add for Expr { type Output = Expr; fn add(self, rhs: Expr) -> Expr { Expr::new_sum(self, rhs) } } impl ops::Add for Expr { type Output = Expr; fn add(self, rhs: Scalar) -> Expr { Expr::new_sum(self, rhs.into()) } } impl ops::Add for Expr { type Output = Expr; fn add(self, rhs: Unknown) -> Expr { Expr::new_sum(self, rhs.into()) } } impl ops::Sub for Expr { type Output = Expr; fn sub(self, rhs: Expr) -> Expr { Expr::new_minus(self, rhs) } } impl ops::Sub for Expr { type Output = Expr; fn sub(self, rhs: Scalar) -> Expr { Expr::new_minus(self, rhs.into()) } } impl ops::Sub for Expr { type Output = Expr; fn sub(self, rhs: Unknown) -> Expr { Expr::new_minus(self, rhs.into()) } } impl ops::Mul for Expr { type Output = Expr; fn mul(self, rhs: Expr) -> Expr { Expr::new_product(self, rhs) } } impl ops::Mul for Expr { type Output = Expr; fn mul(self, rhs: Scalar) -> Expr { Expr::new_product(self, rhs.into()) } } impl ops::Mul for Expr { type Output = Expr; fn mul(self, rhs: Unknown) -> Expr { Expr::new_product(self, rhs.into()) } } impl ops::Div for Expr { type Output = Expr; fn div(self, rhs: Expr) -> Expr { Expr::new_div(self, rhs) } } impl ops::Div for Expr { type Output = Expr; fn div(self, rhs: Scalar) -> Expr { Expr::new_div(self, rhs.into()) } } impl ops::Div for Expr { type Output = Expr; fn div(self, rhs: Unknown) -> Expr { Expr::new_div(self, rhs.into()) } } impl ops::Neg for Expr { type Output = Expr; fn neg(self) -> Expr { Expr::new_neg(self) } } impl ops::Add for Unknown { type Output = Expr; fn add(self, rhs: Expr) -> Expr { Expr::new_sum(self.into(), rhs) } } impl ops::Add for Unknown { type Output = Expr; fn add(self, rhs: Scalar) -> Expr { Expr::new_sum(self.into(), rhs.into()) } } impl ops::Add for Unknown { type Output = Expr; fn add(self, rhs: Unknown) -> Expr { Expr::new_sum(self.into(), rhs.into()) } } impl ops::Sub for Unknown { type Output = Expr; fn sub(self, rhs: Expr) -> Expr { Expr::new_minus(self.into(), rhs) } } impl ops::Sub for Unknown { type Output = Expr; fn sub(self, rhs: Scalar) -> Expr { Expr::new_minus(self.into(), rhs.into()) } } impl ops::Sub for Unknown { type Output = Expr; fn sub(self, rhs: Unknown) -> Expr { Expr::new_minus(self.into(), rhs.into()) } } impl ops::Mul for Unknown { type Output = Expr; fn mul(self, rhs: Expr) -> Expr { Expr::new_product(self.into(), rhs) } } impl ops::Mul for Unknown { type Output = Expr; fn mul(self, rhs: Scalar) -> Expr { Expr::new_product(self.into(), rhs.into()) } } impl ops::Mul for Unknown { type Output = Expr; fn mul(self, rhs: Unknown) -> Expr { Expr::new_product(self.into(), rhs.into()) } } impl ops::Div for Unknown { type Output = Expr; fn div(self, rhs: Expr) -> Expr { Expr::new_div(self.into(), rhs) } } impl ops::Div for Unknown { type Output = Expr; fn div(self, rhs: Scalar) -> Expr { Expr::new_div(self.into(), rhs.into()) } } impl ops::Div for Unknown { type Output = Expr; fn div(self, rhs: Unknown) -> Expr { Expr::new_div(self.into(), rhs.into()) } } impl ops::Neg for Unknown { type Output = Expr; fn neg(self) -> Expr { Expr::new_neg(self.into()) } }