From 544691f070df2da77a87aa41753932bd146a001e Mon Sep 17 00:00:00 2001 From: Bruce Mitchener Date: Sat, 12 Aug 2023 16:37:16 +0700 Subject: [PATCH] clippy: Remove needless borrows. --- src/biguint/monty.rs | 4 ++-- src/biguint/power.rs | 10 +++++----- tests/modpow.rs | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/biguint/monty.rs b/src/biguint/monty.rs index a5c79aa9..573f2dcc 100644 --- a/src/biguint/monty.rs +++ b/src/biguint/monty.rs @@ -78,8 +78,8 @@ fn montgomery(x: &BigUint, y: &BigUint, m: &BigUint, k: BigDigit, n: usize) -> B z.data = z.data[n..].to_vec(); } else { { - let (mut first, second) = z.data.split_at_mut(n); - sub_vv(&mut first, &second, &m.data); + let (first, second) = z.data.split_at_mut(n); + sub_vv(first, second, &m.data); } z.data = z.data[..n].to_vec(); } diff --git a/src/biguint/power.rs b/src/biguint/power.rs index c2add8c4..621e1b15 100644 --- a/src/biguint/power.rs +++ b/src/biguint/power.rs @@ -225,27 +225,27 @@ fn test_plain_modpow() { let exp = vec![0, 0b1]; assert_eq!( two.pow(0b1_00000000_u32) % &modulus, - plain_modpow(&two, &exp, &modulus) + plain_modpow(two, &exp, &modulus) ); let exp = vec![0, 0b10]; assert_eq!( two.pow(0b10_00000000_u32) % &modulus, - plain_modpow(&two, &exp, &modulus) + plain_modpow(two, &exp, &modulus) ); let exp = vec![0, 0b110010]; assert_eq!( two.pow(0b110010_00000000_u32) % &modulus, - plain_modpow(&two, &exp, &modulus) + plain_modpow(two, &exp, &modulus) ); let exp = vec![0b1, 0b1]; assert_eq!( two.pow(0b1_00000001_u32) % &modulus, - plain_modpow(&two, &exp, &modulus) + plain_modpow(two, &exp, &modulus) ); let exp = vec![0b1100, 0, 0b1]; assert_eq!( two.pow(0b1_00000000_00001100_u32) % &modulus, - plain_modpow(&two, &exp, &modulus) + plain_modpow(two, &exp, &modulus) ); } diff --git a/tests/modpow.rs b/tests/modpow.rs index 276f066e..d7a247b0 100644 --- a/tests/modpow.rs +++ b/tests/modpow.rs @@ -120,7 +120,7 @@ mod bigint { let even_m = m << 1u8; let even_modpow = b.modpow(e, m); assert!(even_modpow.abs() < even_m.abs()); - assert_eq!(&even_modpow.mod_floor(&m), r); + assert_eq!(&even_modpow.mod_floor(m), r); // the sign of the result follows the modulus like `mod_floor`, not `rem` assert_eq!(b.modpow(&BigInt::one(), m), b.mod_floor(m));