Skip to content

Commit 793d098

Browse files
authored
Move Uint::square const param WIDE_LIMBS to impl block (#532)
This parameter is inferred via `Concat<Output = Uint<WIDE_LIMBS>`.
1 parent 711144e commit 793d098

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

src/uint/mul.rs

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -90,15 +90,6 @@ impl<const LIMBS: usize> Uint<LIMBS> {
9090
Self::select(&res, &Self::MAX, overflow.is_nonzero())
9191
}
9292

93-
/// Square self, returning a concatenated "wide" result.
94-
pub const fn square<const WIDE_LIMBS: usize>(&self) -> Uint<WIDE_LIMBS>
95-
where
96-
Self: Concat<Output = Uint<WIDE_LIMBS>>,
97-
{
98-
let (lo, hi) = self.square_wide();
99-
concat_mixed(&lo, &hi)
100-
}
101-
10293
/// Square self, returning a "wide" result in two parts as (lo, hi).
10394
pub const fn square_wide(&self) -> (Self, Self) {
10495
// Translated from https://github.com/ucbrise/jedi-pairing/blob/c4bf151/include/core/bigint.hpp#L410
@@ -174,6 +165,17 @@ impl<const LIMBS: usize> Uint<LIMBS> {
174165
}
175166
}
176167

168+
impl<const LIMBS: usize, const WIDE_LIMBS: usize> Uint<LIMBS>
169+
where
170+
Self: Concat<Output = Uint<WIDE_LIMBS>>,
171+
{
172+
/// Square self, returning a concatenated "wide" result.
173+
pub const fn square(&self) -> Uint<WIDE_LIMBS> {
174+
let (lo, hi) = self.square_wide();
175+
concat_mixed(&lo, &hi)
176+
}
177+
}
178+
177179
impl<const LIMBS: usize, const RHS_LIMBS: usize> CheckedMul<Uint<RHS_LIMBS>> for Uint<LIMBS> {
178180
#[inline]
179181
fn checked_mul(&self, rhs: &Uint<RHS_LIMBS>) -> CtOption<Self> {

0 commit comments

Comments
 (0)