Skip to content

Commit fab057c

Browse files
authored
Make Uint::gcd a const fn (#473)
All the prerequisites are there. It was simply an oversight not making it so in #472.
1 parent f990e36 commit fab057c

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/modular/bernstein_yang.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ impl<const SAT_LIMBS: usize, const UNSAT_LIMBS: usize>
9999
///
100100
/// This is defined on this type to piggyback on the definitions for `SAT_LIMBS` and `UNSAT_LIMBS` which are
101101
/// computed when defining `PrecomputeInverter::Inverter` for various `Uint` limb sizes.
102-
pub(crate) fn gcd(f: &Uint<SAT_LIMBS>, g: &Uint<SAT_LIMBS>) -> Uint<SAT_LIMBS> {
102+
pub(crate) const fn gcd(f: &Uint<SAT_LIMBS>, g: &Uint<SAT_LIMBS>) -> Uint<SAT_LIMBS> {
103103
let f_0 = Int62L::from_uint(f);
104104
let inverse = inv_mod2_62(f.as_words());
105105

src/uint/gcd.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ where
1010
/// Compute the greatest common divisor (GCD) of this number and another.
1111
///
1212
/// Panics if `self` is odd.
13-
pub fn gcd(&self, rhs: &Self) -> Self {
14-
debug_assert!(bool::from(self.is_odd()));
13+
pub const fn gcd(&self, rhs: &Self) -> Self {
14+
debug_assert!(self.is_odd().is_true_vartime());
1515
<Self as PrecomputeInverter>::Inverter::gcd(self, rhs)
1616
}
1717
}

0 commit comments

Comments
 (0)