Skip to content

Commit

Permalink
clippy: Remove needless borrows.
Browse files Browse the repository at this point in the history
  • Loading branch information
waywardmonkeys authored and cuviper committed Aug 22, 2023
1 parent dc9a828 commit 544691f
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/biguint/monty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
10 changes: 5 additions & 5 deletions src/biguint/power.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
);
}

Expand Down
2 changes: 1 addition & 1 deletion tests/modpow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down

0 comments on commit 544691f

Please sign in to comment.