diff --git a/src/uint/div.rs b/src/uint/div.rs index 7ce2f176..54536383 100644 --- a/src/uint/div.rs +++ b/src/uint/div.rs @@ -195,46 +195,46 @@ where } } -impl Div<&Wrapping>> for &Wrapping> { +impl Div>> for Wrapping> { type Output = Wrapping>; - fn div(self, rhs: &Wrapping>) -> Self::Output { - *self / *rhs + fn div(self, rhs: NonZero>) -> Self::Output { + Wrapping(self.0.wrapping_div(rhs.as_ref())) } } -impl Div<&Wrapping>> for Wrapping> { +impl Div>> for &Wrapping> { type Output = Wrapping>; - fn div(self, rhs: &Wrapping>) -> Self::Output { - self / *rhs + fn div(self, rhs: NonZero>) -> Self::Output { + *self / rhs } } -impl Div>> for &Wrapping> { +impl Div<&NonZero>> for &Wrapping> { type Output = Wrapping>; - fn div(self, rhs: Wrapping>) -> Self::Output { - *self / rhs + fn div(self, rhs: &NonZero>) -> Self::Output { + *self / *rhs } } -impl Div for Wrapping> { +impl Div<&NonZero>> for Wrapping> { type Output = Wrapping>; - fn div(self, rhs: Self) -> Self::Output { - Wrapping(self.0.checked_div(&rhs.0).unwrap()) + fn div(self, rhs: &NonZero>) -> Self::Output { + self / *rhs } } -impl DivAssign<&Wrapping>> for Wrapping> { - fn div_assign(&mut self, rhs: &Wrapping>) { - *self = Wrapping(self.0.checked_div(&rhs.0).unwrap()) +impl DivAssign<&NonZero>> for Wrapping> { + fn div_assign(&mut self, rhs: &NonZero>) { + *self = Wrapping(self.0.wrapping_div(rhs.as_ref())) } } -impl DivAssign for Wrapping> { - fn div_assign(&mut self, rhs: Self) { +impl DivAssign>> for Wrapping> { + fn div_assign(&mut self, rhs: NonZero>) { *self /= &rhs; } } @@ -303,47 +303,47 @@ where } } -impl Rem<&Wrapping>> for &Wrapping> { +impl Rem>> for Wrapping> { type Output = Wrapping>; - fn rem(self, rhs: &Wrapping>) -> Self::Output { - *self % *rhs + fn rem(self, rhs: NonZero>) -> Self::Output { + Wrapping(self.0.wrapping_rem(rhs.as_ref())) } } -impl Rem<&Wrapping>> for Wrapping> { +impl Rem>> for &Wrapping> { type Output = Wrapping>; - fn rem(self, rhs: &Wrapping>) -> Self::Output { - self % *rhs + fn rem(self, rhs: NonZero>) -> Self::Output { + *self % rhs } } -impl Rem>> for &Wrapping> { +impl Rem<&NonZero>> for &Wrapping> { type Output = Wrapping>; - fn rem(self, rhs: Wrapping>) -> Self::Output { - *self % rhs + fn rem(self, rhs: &NonZero>) -> Self::Output { + *self % *rhs } } -impl Rem for Wrapping> { +impl Rem<&NonZero>> for Wrapping> { type Output = Wrapping>; - fn rem(self, rhs: Wrapping>) -> Self::Output { - Wrapping(self.0.checked_rem(&rhs.0).unwrap()) + fn rem(self, rhs: &NonZero>) -> Self::Output { + self % *rhs } } -impl RemAssign<&Wrapping>> for Wrapping> { - fn rem_assign(&mut self, rhs: &Wrapping>) { - *self = Wrapping(self.0.checked_rem(&rhs.0).unwrap()) +impl RemAssign>> for Wrapping> { + fn rem_assign(&mut self, rhs: NonZero>) { + *self %= &rhs; } } -impl RemAssign for Wrapping> { - fn rem_assign(&mut self, rhs: Self) { - *self %= &rhs; +impl RemAssign<&NonZero>> for Wrapping> { + fn rem_assign(&mut self, rhs: &NonZero>) { + *self = Wrapping(self.0.wrapping_rem(rhs.as_ref())) } }