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
use std::ops::*; trait Ops<Rhs=Self, Output=Self>: Add<Rhs, Output = Output> + Sub<Rhs, Output = Output> + Mul<Rhs, Output = Output> + Div<Rhs, Output = Output> + Rem<Rhs, Output = Output> {} trait OpsAssign<Rhs=Self>: AddAssign<Rhs> + SubAssign<Rhs> + MulAssign<Rhs> + DivAssign<Rhs> + RemAssign<Rhs> {} trait Zero { fn zero() -> Self; fn is_zero(&self) -> bool; fn set_zero(&self); } trait One { fn one() -> Self; fn is_one(&self) -> bool; fn set_one(&self); } trait Num: PartialEq + Ops + OpsAssign + One + Zero + Copy + Clone + Sized {}