1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72
use expr::Expr; use std::convert::Into; pub trait And<T, RHS> { fn and(self, rhs: RHS) -> Expr<T>; } impl<T, LHS, RHS> And<T, RHS> for LHS where RHS: Into<Expr<T>>, LHS: Into<Expr<T>>, { fn and(self, e: RHS) -> Expr<T> { Expr::And(Box::new(self.into()), Box::new(e.into())) } } pub trait Or<T, RHS> { fn or(self, rhs: RHS) -> Expr<T>; } impl<T, LHS, RHS> Or<T, RHS> for LHS where RHS: Into<Expr<T>>, LHS: Into<Expr<T>>, { fn or(self, e: RHS) -> Expr<T> { Expr::Or(Box::new(self.into()), Box::new(e.into())) } } pub trait Xor<T, RHS> { fn xor(self, rhs: RHS) -> Expr<T>; } impl<T, LHS, RHS> Xor<T, RHS> for LHS where RHS: Into<Expr<T>>, LHS: Into<Expr<T>>, { fn xor(self, e: RHS) -> Expr<T> { Expr::Xor(Box::new(self.into()), Box::new(e.into())) } } pub trait Implies<T, RHS> { fn implies(self, rhs: RHS) -> Expr<T>; } impl<T, LHS, RHS> Implies<T, RHS> for LHS where RHS: Into<Expr<T>>, LHS: Into<Expr<T>>, { fn implies(self, e: RHS) -> Expr<T> { Expr::Implies(Box::new(self.into()), Box::new(e.into())) } } pub trait Equivalent<T, RHS> { fn equivalent(self, rhs: RHS) -> Expr<T>; } impl<T, LHS, RHS> Equivalent<T, RHS> for LHS where RHS: Into<Expr<T>>, LHS: Into<Expr<T>>, { fn equivalent(self, e: RHS) -> Expr<T> { Expr::Equivalent(Box::new(self.into()), Box::new(e.into())) } }