@@ -52,22 +52,25 @@ macro_rules! impl_schoolbook_multiplication {
5252
5353impl < const LIMBS : usize > Uint < LIMBS > {
5454 /// Multiply `self` by `rhs`, returning a concatenated "wide" result.
55- pub fn widening_mul < const HLIMBS : usize > (
55+ pub fn widening_mul < const RHS_LIMBS : usize > (
5656 & self ,
57- rhs : & Uint < HLIMBS > ,
58- ) -> <Uint < HLIMBS > as ConcatMixed < Self > >:: MixedOutput
57+ rhs : & Uint < RHS_LIMBS > ,
58+ ) -> <Uint < RHS_LIMBS > as ConcatMixed < Self > >:: MixedOutput
5959 where
60- Uint < HLIMBS > : ConcatMixed < Self > ,
60+ Uint < RHS_LIMBS > : ConcatMixed < Self > ,
6161 {
6262 let ( lo, hi) = self . split_mul ( rhs) ;
6363 hi. concat_mixed ( & lo)
6464 }
6565
6666 /// Compute "wide" multiplication as a 2-tuple containing the `(lo, hi)` components of the product, whose sizes
6767 /// correspond to the sizes of the operands.
68- pub const fn split_mul < const HLIMBS : usize > ( & self , rhs : & Uint < HLIMBS > ) -> ( Self , Uint < HLIMBS > ) {
68+ pub const fn split_mul < const RHS_LIMBS : usize > (
69+ & self ,
70+ rhs : & Uint < RHS_LIMBS > ,
71+ ) -> ( Self , Uint < RHS_LIMBS > ) {
6972 let mut lo = Self :: ZERO ;
70- let mut hi = Uint :: < HLIMBS > :: ZERO ;
73+ let mut hi = Uint :: < RHS_LIMBS > :: ZERO ;
7174 impl_schoolbook_multiplication ! ( & self . limbs, & rhs. limbs, lo. limbs, hi. limbs) ;
7275 ( lo, hi)
7376 }
@@ -78,7 +81,7 @@ impl<const LIMBS: usize> Uint<LIMBS> {
7881 }
7982
8083 /// Perform saturating multiplication, returning `MAX` on overflow.
81- pub const fn saturating_mul < const HLIMBS : usize > ( & self , rhs : & Uint < HLIMBS > ) -> Self {
84+ pub const fn saturating_mul < const RHS_LIMBS : usize > ( & self , rhs : & Uint < RHS_LIMBS > ) -> Self {
8285 let ( res, overflow) = self . split_mul ( rhs) ;
8386 Self :: select ( & res, & Self :: MAX , overflow. is_nonzero ( ) )
8487 }
@@ -167,184 +170,190 @@ impl<const LIMBS: usize> Uint<LIMBS> {
167170 }
168171}
169172
170- impl < const LIMBS : usize , const HLIMBS : usize > CheckedMul < Uint < HLIMBS > > for Uint < LIMBS > {
173+ impl < const LIMBS : usize , const RHS_LIMBS : usize > CheckedMul < Uint < RHS_LIMBS > > for Uint < LIMBS > {
171174 type Output = Uint < LIMBS > ;
172175
173176 #[ inline]
174- fn checked_mul ( & self , rhs : Uint < HLIMBS > ) -> CtOption < Self > {
177+ fn checked_mul ( & self , rhs : Uint < RHS_LIMBS > ) -> CtOption < Self > {
175178 self . checked_mul ( & rhs)
176179 }
177180}
178181
179- impl < const LIMBS : usize , const HLIMBS : usize > CheckedMul < & Uint < HLIMBS > > for Uint < LIMBS > {
182+ impl < const LIMBS : usize , const RHS_LIMBS : usize > CheckedMul < & Uint < RHS_LIMBS > > for Uint < LIMBS > {
180183 type Output = Uint < LIMBS > ;
181184
182185 #[ inline]
183- fn checked_mul ( & self , rhs : & Uint < HLIMBS > ) -> CtOption < Self > {
186+ fn checked_mul ( & self , rhs : & Uint < RHS_LIMBS > ) -> CtOption < Self > {
184187 let ( lo, hi) = self . split_mul ( rhs) ;
185188 CtOption :: new ( lo, hi. is_zero ( ) )
186189 }
187190}
188191
189- impl < const LIMBS : usize , const HLIMBS : usize > Mul < Uint < HLIMBS > > for Uint < LIMBS > {
192+ impl < const LIMBS : usize , const RHS_LIMBS : usize > Mul < Uint < RHS_LIMBS > > for Uint < LIMBS > {
190193 type Output = Uint < LIMBS > ;
191194
192- fn mul ( self , rhs : Uint < HLIMBS > ) -> Self {
195+ fn mul ( self , rhs : Uint < RHS_LIMBS > ) -> Self {
193196 self . mul ( & rhs)
194197 }
195198}
196199
197- impl < const LIMBS : usize , const HLIMBS : usize > Mul < & Uint < HLIMBS > > for Uint < LIMBS > {
200+ impl < const LIMBS : usize , const RHS_LIMBS : usize > Mul < & Uint < RHS_LIMBS > > for Uint < LIMBS > {
198201 type Output = Uint < LIMBS > ;
199202
200- fn mul ( self , rhs : & Uint < HLIMBS > ) -> Self {
203+ fn mul ( self , rhs : & Uint < RHS_LIMBS > ) -> Self {
201204 ( & self ) . mul ( rhs)
202205 }
203206}
204207
205- impl < const LIMBS : usize , const HLIMBS : usize > Mul < Uint < HLIMBS > > for & Uint < LIMBS > {
208+ impl < const LIMBS : usize , const RHS_LIMBS : usize > Mul < Uint < RHS_LIMBS > > for & Uint < LIMBS > {
206209 type Output = Uint < LIMBS > ;
207210
208- fn mul ( self , rhs : Uint < HLIMBS > ) -> Self :: Output {
211+ fn mul ( self , rhs : Uint < RHS_LIMBS > ) -> Self :: Output {
209212 self . mul ( & rhs)
210213 }
211214}
212215
213- impl < const LIMBS : usize , const HLIMBS : usize > Mul < & Uint < HLIMBS > > for & Uint < LIMBS > {
216+ impl < const LIMBS : usize , const RHS_LIMBS : usize > Mul < & Uint < RHS_LIMBS > > for & Uint < LIMBS > {
214217 type Output = Uint < LIMBS > ;
215218
216- fn mul ( self , rhs : & Uint < HLIMBS > ) -> Self :: Output {
219+ fn mul ( self , rhs : & Uint < RHS_LIMBS > ) -> Self :: Output {
217220 self . checked_mul ( rhs)
218221 . expect ( "attempted to multiply with overflow" )
219222 }
220223}
221224
222- impl < const LIMBS : usize , const HLIMBS : usize > Mul < Wrapping < Uint < HLIMBS > > >
225+ impl < const LIMBS : usize , const RHS_LIMBS : usize > Mul < Wrapping < Uint < RHS_LIMBS > > >
223226 for Wrapping < Uint < LIMBS > >
224227{
225228 type Output = Self ;
226229
227- fn mul ( self , rhs : Wrapping < Uint < HLIMBS > > ) -> Wrapping < Uint < LIMBS > > {
230+ fn mul ( self , rhs : Wrapping < Uint < RHS_LIMBS > > ) -> Wrapping < Uint < LIMBS > > {
228231 Wrapping ( self . 0 . wrapping_mul ( & rhs. 0 ) )
229232 }
230233}
231234
232- impl < const LIMBS : usize , const HLIMBS : usize > Mul < & Wrapping < Uint < HLIMBS > > >
235+ impl < const LIMBS : usize , const RHS_LIMBS : usize > Mul < & Wrapping < Uint < RHS_LIMBS > > >
233236 for Wrapping < Uint < LIMBS > >
234237{
235238 type Output = Self ;
236239
237- fn mul ( self , rhs : & Wrapping < Uint < HLIMBS > > ) -> Wrapping < Uint < LIMBS > > {
240+ fn mul ( self , rhs : & Wrapping < Uint < RHS_LIMBS > > ) -> Wrapping < Uint < LIMBS > > {
238241 Wrapping ( self . 0 . wrapping_mul ( & rhs. 0 ) )
239242 }
240243}
241244
242- impl < const LIMBS : usize , const HLIMBS : usize > Mul < Wrapping < Uint < HLIMBS > > >
245+ impl < const LIMBS : usize , const RHS_LIMBS : usize > Mul < Wrapping < Uint < RHS_LIMBS > > >
243246 for & Wrapping < Uint < LIMBS > >
244247{
245248 type Output = Wrapping < Uint < LIMBS > > ;
246249
247- fn mul ( self , rhs : Wrapping < Uint < HLIMBS > > ) -> Wrapping < Uint < LIMBS > > {
250+ fn mul ( self , rhs : Wrapping < Uint < RHS_LIMBS > > ) -> Wrapping < Uint < LIMBS > > {
248251 Wrapping ( self . 0 . wrapping_mul ( & rhs. 0 ) )
249252 }
250253}
251254
252- impl < const LIMBS : usize , const HLIMBS : usize > Mul < & Wrapping < Uint < HLIMBS > > >
255+ impl < const LIMBS : usize , const RHS_LIMBS : usize > Mul < & Wrapping < Uint < RHS_LIMBS > > >
253256 for & Wrapping < Uint < LIMBS > >
254257{
255258 type Output = Wrapping < Uint < LIMBS > > ;
256259
257- fn mul ( self , rhs : & Wrapping < Uint < HLIMBS > > ) -> Wrapping < Uint < LIMBS > > {
260+ fn mul ( self , rhs : & Wrapping < Uint < RHS_LIMBS > > ) -> Wrapping < Uint < LIMBS > > {
258261 Wrapping ( self . 0 . wrapping_mul ( & rhs. 0 ) )
259262 }
260263}
261264
262- impl < const LIMBS : usize , const HLIMBS : usize > MulAssign < Wrapping < Uint < HLIMBS > > >
265+ impl < const LIMBS : usize , const RHS_LIMBS : usize > MulAssign < Wrapping < Uint < RHS_LIMBS > > >
263266 for Wrapping < Uint < LIMBS > >
264267{
265- fn mul_assign ( & mut self , other : Wrapping < Uint < HLIMBS > > ) {
268+ fn mul_assign ( & mut self , other : Wrapping < Uint < RHS_LIMBS > > ) {
266269 * self = * self * other;
267270 }
268271}
269272
270- impl < const LIMBS : usize , const HLIMBS : usize > MulAssign < & Wrapping < Uint < HLIMBS > > >
273+ impl < const LIMBS : usize , const RHS_LIMBS : usize > MulAssign < & Wrapping < Uint < RHS_LIMBS > > >
271274 for Wrapping < Uint < LIMBS > >
272275{
273- fn mul_assign ( & mut self , other : & Wrapping < Uint < HLIMBS > > ) {
276+ fn mul_assign ( & mut self , other : & Wrapping < Uint < RHS_LIMBS > > ) {
274277 * self = * self * other;
275278 }
276279}
277280
278- impl < const LIMBS : usize , const HLIMBS : usize > Mul < Checked < Uint < HLIMBS > > > for Checked < Uint < LIMBS > > {
281+ impl < const LIMBS : usize , const RHS_LIMBS : usize > Mul < Checked < Uint < RHS_LIMBS > > >
282+ for Checked < Uint < LIMBS > >
283+ {
279284 type Output = Self ;
280285
281- fn mul ( self , rhs : Checked < Uint < HLIMBS > > ) -> Checked < Uint < LIMBS > > {
286+ fn mul ( self , rhs : Checked < Uint < RHS_LIMBS > > ) -> Checked < Uint < LIMBS > > {
282287 Checked ( self . 0 . and_then ( |a| rhs. 0 . and_then ( |b| a. checked_mul ( & b) ) ) )
283288 }
284289}
285290
286- impl < const LIMBS : usize , const HLIMBS : usize > Mul < & Checked < Uint < HLIMBS > > > for Checked < Uint < LIMBS > > {
291+ impl < const LIMBS : usize , const RHS_LIMBS : usize > Mul < & Checked < Uint < RHS_LIMBS > > >
292+ for Checked < Uint < LIMBS > >
293+ {
287294 type Output = Checked < Uint < LIMBS > > ;
288295
289- fn mul ( self , rhs : & Checked < Uint < HLIMBS > > ) -> Checked < Uint < LIMBS > > {
296+ fn mul ( self , rhs : & Checked < Uint < RHS_LIMBS > > ) -> Checked < Uint < LIMBS > > {
290297 Checked ( self . 0 . and_then ( |a| rhs. 0 . and_then ( |b| a. checked_mul ( & b) ) ) )
291298 }
292299}
293300
294- impl < const LIMBS : usize , const HLIMBS : usize > Mul < Checked < Uint < HLIMBS > > > for & Checked < Uint < LIMBS > > {
301+ impl < const LIMBS : usize , const RHS_LIMBS : usize > Mul < Checked < Uint < RHS_LIMBS > > >
302+ for & Checked < Uint < LIMBS > >
303+ {
295304 type Output = Checked < Uint < LIMBS > > ;
296305
297- fn mul ( self , rhs : Checked < Uint < HLIMBS > > ) -> Checked < Uint < LIMBS > > {
306+ fn mul ( self , rhs : Checked < Uint < RHS_LIMBS > > ) -> Checked < Uint < LIMBS > > {
298307 Checked ( self . 0 . and_then ( |a| rhs. 0 . and_then ( |b| a. checked_mul ( & b) ) ) )
299308 }
300309}
301310
302- impl < const LIMBS : usize , const HLIMBS : usize > Mul < & Checked < Uint < HLIMBS > > >
311+ impl < const LIMBS : usize , const RHS_LIMBS : usize > Mul < & Checked < Uint < RHS_LIMBS > > >
303312 for & Checked < Uint < LIMBS > >
304313{
305314 type Output = Checked < Uint < LIMBS > > ;
306315
307- fn mul ( self , rhs : & Checked < Uint < HLIMBS > > ) -> Checked < Uint < LIMBS > > {
316+ fn mul ( self , rhs : & Checked < Uint < RHS_LIMBS > > ) -> Checked < Uint < LIMBS > > {
308317 Checked ( self . 0 . and_then ( |a| rhs. 0 . and_then ( |b| a. checked_mul ( & b) ) ) )
309318 }
310319}
311320
312- impl < const LIMBS : usize , const HLIMBS : usize > MulAssign < Checked < Uint < HLIMBS > > >
321+ impl < const LIMBS : usize , const RHS_LIMBS : usize > MulAssign < Checked < Uint < RHS_LIMBS > > >
313322 for Checked < Uint < LIMBS > >
314323{
315- fn mul_assign ( & mut self , other : Checked < Uint < HLIMBS > > ) {
324+ fn mul_assign ( & mut self , other : Checked < Uint < RHS_LIMBS > > ) {
316325 * self = * self * other;
317326 }
318327}
319328
320- impl < const LIMBS : usize , const HLIMBS : usize > MulAssign < & Checked < Uint < HLIMBS > > >
329+ impl < const LIMBS : usize , const RHS_LIMBS : usize > MulAssign < & Checked < Uint < RHS_LIMBS > > >
321330 for Checked < Uint < LIMBS > >
322331{
323- fn mul_assign ( & mut self , other : & Checked < Uint < HLIMBS > > ) {
332+ fn mul_assign ( & mut self , other : & Checked < Uint < RHS_LIMBS > > ) {
324333 * self = * self * other;
325334 }
326335}
327336
328- impl < const LIMBS : usize , const HLIMBS : usize > WideningMul < Uint < HLIMBS > > for Uint < LIMBS >
337+ impl < const LIMBS : usize , const RHS_LIMBS : usize > WideningMul < Uint < RHS_LIMBS > > for Uint < LIMBS >
329338where
330- Uint < HLIMBS > : ConcatMixed < Self > ,
339+ Uint < RHS_LIMBS > : ConcatMixed < Self > ,
331340{
332- type Output = <Uint < HLIMBS > as ConcatMixed < Self > >:: MixedOutput ;
341+ type Output = <Uint < RHS_LIMBS > as ConcatMixed < Self > >:: MixedOutput ;
333342
334343 #[ inline]
335- fn widening_mul ( & self , rhs : Uint < HLIMBS > ) -> Self :: Output {
344+ fn widening_mul ( & self , rhs : Uint < RHS_LIMBS > ) -> Self :: Output {
336345 self . widening_mul ( & rhs)
337346 }
338347}
339348
340- impl < const LIMBS : usize , const HLIMBS : usize > WideningMul < & Uint < HLIMBS > > for Uint < LIMBS >
349+ impl < const LIMBS : usize , const RHS_LIMBS : usize > WideningMul < & Uint < RHS_LIMBS > > for Uint < LIMBS >
341350where
342- Uint < HLIMBS > : ConcatMixed < Self > ,
351+ Uint < RHS_LIMBS > : ConcatMixed < Self > ,
343352{
344- type Output = <Uint < HLIMBS > as ConcatMixed < Self > >:: MixedOutput ;
353+ type Output = <Uint < RHS_LIMBS > as ConcatMixed < Self > >:: MixedOutput ;
345354
346355 #[ inline]
347- fn widening_mul ( & self , rhs : & Uint < HLIMBS > ) -> Self :: Output {
356+ fn widening_mul ( & self , rhs : & Uint < RHS_LIMBS > ) -> Self :: Output {
348357 self . widening_mul ( rhs)
349358 }
350359}
0 commit comments