diff --git a/src/add.rs b/src/add.rs index 22ba503e..6d52022b 100644 --- a/src/add.rs +++ b/src/add.rs @@ -64,7 +64,7 @@ impl Uint { } let mut carry = 0_u128; #[allow(clippy::cast_possible_truncation)] // Intentional - for (lhs, rhs) in self.limbs.iter_mut().zip(rhs.limbs) { + for (lhs, &rhs) in self.limbs.iter_mut().zip(rhs.as_limbs()) { carry += u128::from(*lhs) + u128::from(rhs); *lhs = carry as u64; carry >>= 64; @@ -100,7 +100,7 @@ impl Uint { let mut carry = 0_i128; #[allow(clippy::cast_possible_truncation)] // Intentional #[allow(clippy::cast_sign_loss)] // Intentional - for (lhs, rhs) in self.limbs.iter_mut().zip(rhs.limbs) { + for (lhs, &rhs) in self.limbs.iter_mut().zip(rhs.as_limbs()) { carry += i128::from(*lhs) - i128::from(rhs); *lhs = carry as u64; carry >>= 64; // Sign extending shift diff --git a/src/base_convert.rs b/src/base_convert.rs index 65bfe9e2..983d85c5 100644 --- a/src/base_convert.rs +++ b/src/base_convert.rs @@ -125,7 +125,7 @@ impl Uint { } // Add digit to result - let overflow = addmul_nx1(&mut result.limbs, &power.limbs, digit); + let overflow = addmul_nx1(&mut result.limbs, power.as_limbs(), digit); if overflow != 0 || result.limbs[LIMBS - 1] > Self::MASK { return Err(BaseConvertError::Overflow); } diff --git a/src/bits.rs b/src/bits.rs index 0a510737..b5537e6a 100644 --- a/src/bits.rs +++ b/src/bits.rs @@ -479,7 +479,7 @@ macro_rules! impl_bit_op { for Uint { fn $fn_assign(&mut self, rhs: &Uint) { - for (limb, rhs) in self.limbs.iter_mut().zip(rhs.limbs) { + for (limb, &rhs) in self.limbs.iter_mut().zip(rhs.as_limbs()) { u64::$fn_assign(limb, rhs); } } diff --git a/src/modular.rs b/src/modular.rs index c44af184..07d2216b 100644 --- a/src/modular.rs +++ b/src/modular.rs @@ -61,7 +61,7 @@ impl Uint { // Alternatively we could use `alloca`, but that is blocked on // See let mut product = vec![0; crate::nlimbs(2 * BITS)]; - let overflow = algorithms::addmul(&mut product, &self.limbs, &rhs.limbs); + let overflow = algorithms::addmul(&mut product, self.as_limbs(), rhs.as_limbs()); debug_assert!(!overflow); // Compute modulus using `div_rem`. @@ -152,10 +152,10 @@ impl Uint { assert_eq!(inv.wrapping_mul(modulus.limbs[0]), u64::MAX); let mut result = Self::ZERO; algorithms::mul_redc( - &self.limbs, - &other.limbs, + self.as_limbs(), + other.as_limbs(), &mut result.limbs, - &modulus.limbs, + modulus.as_limbs(), inv, ); debug_assert!(result < modulus); diff --git a/src/mul.rs b/src/mul.rs index f33d206b..050ccee2 100644 --- a/src/mul.rs +++ b/src/mul.rs @@ -140,7 +140,7 @@ impl Uint { assert_eq!(BITS_RES, BITS + BITS_RHS); assert_eq!(LIMBS_RES, nlimbs(BITS_RES)); let mut result = Uint::::ZERO; - algorithms::addmul(&mut result.limbs, &self.limbs, &rhs.limbs); + algorithms::addmul(&mut result.limbs, self.as_limbs(), rhs.as_limbs()); if LIMBS_RES > 0 { debug_assert!(result.limbs[LIMBS_RES - 1] <= Uint::::MASK); }