diff --git a/src/div.rs b/src/div.rs index ad6b757..36b3e57 100644 --- a/src/div.rs +++ b/src/div.rs @@ -7,7 +7,7 @@ impl Uint { #[must_use] #[allow(clippy::missing_const_for_fn)] // False positive pub fn checked_div(self, rhs: Self) -> Option { - if rhs == Self::ZERO { + if rhs.is_zero() { return None; } Some(self.div(rhs)) @@ -18,7 +18,7 @@ impl Uint { #[must_use] #[allow(clippy::missing_const_for_fn)] // False positive pub fn checked_rem(self, rhs: Self) -> Option { - if rhs == Self::ZERO { + if rhs.is_zero() { return None; } Some(self.rem(rhs)) @@ -35,7 +35,7 @@ impl Uint { pub fn div_ceil(self, rhs: Self) -> Self { assert!(rhs != Self::ZERO, "Division by zero"); let (q, r) = self.div_rem(rhs); - if r == Self::ZERO { + if r.is_zero() { q } else { q + Self::from(1) diff --git a/src/log.rs b/src/log.rs index 84e0fa5..3c0bb68 100644 --- a/src/log.rs +++ b/src/log.rs @@ -9,7 +9,7 @@ impl Uint { #[inline] #[must_use] pub fn checked_log(self, base: Self) -> Option { - if base < Self::from(2) || self == Self::ZERO { + if base < Self::from(2) || self.is_zero() { return None; } Some(self.log(base)) diff --git a/src/modular.rs b/src/modular.rs index 3970b52..4969ccf 100644 --- a/src/modular.rs +++ b/src/modular.rs @@ -17,7 +17,7 @@ impl Uint { #[inline] #[must_use] pub fn reduce_mod(mut self, modulus: Self) -> Self { - if modulus == Self::ZERO { + if modulus.is_zero() { return Self::ZERO; } if self >= modulus { @@ -53,7 +53,7 @@ impl Uint { #[inline] #[must_use] pub fn mul_mod(self, rhs: Self, mut modulus: Self) -> Self { - if modulus == Self::ZERO { + if modulus.is_zero() { return Self::ZERO; } @@ -84,7 +84,7 @@ impl Uint { #[inline] #[must_use] pub fn pow_mod(mut self, mut exp: Self, modulus: Self) -> Self { - if modulus == Self::ZERO || modulus <= Self::from(1) { + if modulus.is_zero() || modulus <= Self::from(1) { // Also covers Self::BITS == 0 return Self::ZERO; } diff --git a/src/root.rs b/src/root.rs index 695218a..d99b727 100644 --- a/src/root.rs +++ b/src/root.rs @@ -31,7 +31,7 @@ impl Uint { assert!(degree > 0, "degree must be greater than zero"); // Handle zero case (including BITS == 0). - if self == Self::ZERO { + if self.is_zero() { return Self::ZERO; } diff --git a/src/special.rs b/src/special.rs index cda9689..11fa8b9 100644 --- a/src/special.rs +++ b/src/special.rs @@ -109,11 +109,11 @@ impl Uint { #[inline] #[must_use] pub fn checked_next_multiple_of(self, rhs: Self) -> Option { - if rhs == Self::ZERO { + if rhs.is_zero() { return None; } let (q, r) = self.div_rem(rhs); - if r == Self::ZERO { + if r.is_zero() { return Some(self); } let q = q.checked_add(Self::from(1))?;