diff --git a/src/lib.rs b/src/lib.rs index b1cf2a4..3197f89 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -246,7 +246,7 @@ impl Ratio { }; if half_or_larger { - let one: Ratio = One::one(); + let one: T = One::one(); if *self >= Zero::zero() { self.trunc() + one } else { @@ -883,8 +883,9 @@ where type Output = Ratio; #[inline] - fn neg(self) -> Ratio { - Ratio::new_raw(-self.numer, self.denom) + fn neg(mut self) -> Ratio { + self.numer = -self.numer; + self } } @@ -908,7 +909,7 @@ where #[inline] fn inv(self) -> Ratio { - self.recip() + self.into_recip() } }