@@ -209,7 +209,10 @@ impl<const N: usize> SignedBigInt<N> {
209209 /// Debug-asserts that M <= N.
210210 #[ inline]
211211 pub fn zero_extend_from < const M : usize > ( smaller : & SignedBigInt < M > ) -> SignedBigInt < N > {
212- debug_assert ! ( M <= N , "cannot zero-extend: source has more limbs than destination" ) ;
212+ debug_assert ! (
213+ M <= N ,
214+ "cannot zero-extend: source has more limbs than destination"
215+ ) ;
213216 let widened_mag = BigInt :: < N > :: zero_extend_from :: < M > ( & smaller. magnitude ) ;
214217 SignedBigInt :: from_bigint ( widened_mag, smaller. is_positive )
215218 }
@@ -223,16 +226,25 @@ impl<const N: usize> SignedBigInt<N> {
223226 pub fn add_trunc < const M : usize > ( & self , rhs : & SignedBigInt < N > ) -> SignedBigInt < M > {
224227 if self . is_positive == rhs. is_positive {
225228 let mag = self . magnitude . add_trunc :: < N , M > ( & rhs. magnitude ) ;
226- return SignedBigInt :: < M > { magnitude : mag, is_positive : self . is_positive } ;
229+ return SignedBigInt :: < M > {
230+ magnitude : mag,
231+ is_positive : self . is_positive ,
232+ } ;
227233 }
228234 match self . magnitude . cmp ( & rhs. magnitude ) {
229235 Ordering :: Greater | Ordering :: Equal => {
230236 let mag = self . magnitude . sub_trunc :: < N , M > ( & rhs. magnitude ) ;
231- SignedBigInt :: < M > { magnitude : mag, is_positive : self . is_positive }
237+ SignedBigInt :: < M > {
238+ magnitude : mag,
239+ is_positive : self . is_positive ,
240+ }
232241 } ,
233242 Ordering :: Less => {
234243 let mag = rhs. magnitude . sub_trunc :: < N , M > ( & self . magnitude ) ;
235- SignedBigInt :: < M > { magnitude : mag, is_positive : rhs. is_positive }
244+ SignedBigInt :: < M > {
245+ magnitude : mag,
246+ is_positive : rhs. is_positive ,
247+ }
236248 } ,
237249 }
238250 }
@@ -242,16 +254,25 @@ impl<const N: usize> SignedBigInt<N> {
242254 pub fn sub_trunc < const M : usize > ( & self , rhs : & SignedBigInt < N > ) -> SignedBigInt < M > {
243255 if self . is_positive != rhs. is_positive {
244256 let mag = self . magnitude . add_trunc :: < N , M > ( & rhs. magnitude ) ;
245- return SignedBigInt :: < M > { magnitude : mag, is_positive : self . is_positive } ;
257+ return SignedBigInt :: < M > {
258+ magnitude : mag,
259+ is_positive : self . is_positive ,
260+ } ;
246261 }
247262 match self . magnitude . cmp ( & rhs. magnitude ) {
248263 Ordering :: Greater | Ordering :: Equal => {
249264 let mag = self . magnitude . sub_trunc :: < N , M > ( & rhs. magnitude ) ;
250- SignedBigInt :: < M > { magnitude : mag, is_positive : self . is_positive }
265+ SignedBigInt :: < M > {
266+ magnitude : mag,
267+ is_positive : self . is_positive ,
268+ }
251269 } ,
252270 Ordering :: Less => {
253271 let mag = rhs. magnitude . sub_trunc :: < N , M > ( & self . magnitude ) ;
254- SignedBigInt :: < M > { magnitude : mag, is_positive : !self . is_positive }
272+ SignedBigInt :: < M > {
273+ magnitude : mag,
274+ is_positive : !self . is_positive ,
275+ }
255276 } ,
256277 }
257278 }
@@ -265,16 +286,25 @@ impl<const N: usize> SignedBigInt<N> {
265286 ) -> SignedBigInt < P > {
266287 if self . is_positive == rhs. is_positive {
267288 let mag = self . magnitude . add_trunc :: < M , P > ( & rhs. magnitude ) ;
268- return SignedBigInt :: < P > { magnitude : mag, is_positive : self . is_positive } ;
289+ return SignedBigInt :: < P > {
290+ magnitude : mag,
291+ is_positive : self . is_positive ,
292+ } ;
269293 }
270294 match self . cmp_magnitude_mixed ( rhs) {
271295 Ordering :: Greater | Ordering :: Equal => {
272296 let mag = self . magnitude . sub_trunc :: < M , P > ( & rhs. magnitude ) ;
273- SignedBigInt :: < P > { magnitude : mag, is_positive : self . is_positive }
297+ SignedBigInt :: < P > {
298+ magnitude : mag,
299+ is_positive : self . is_positive ,
300+ }
274301 } ,
275302 Ordering :: Less => {
276303 let mag = rhs. magnitude . sub_trunc :: < N , P > ( & self . magnitude ) ;
277- SignedBigInt :: < P > { magnitude : mag, is_positive : rhs. is_positive }
304+ SignedBigInt :: < P > {
305+ magnitude : mag,
306+ is_positive : rhs. is_positive ,
307+ }
278308 } ,
279309 }
280310 }
@@ -373,16 +403,25 @@ impl<const N: usize> SignedBigInt<N> {
373403 ) -> SignedBigInt < P > {
374404 if self . is_positive != rhs. is_positive {
375405 let mag = self . magnitude . add_trunc :: < M , P > ( & rhs. magnitude ) ;
376- return SignedBigInt :: < P > { magnitude : mag, is_positive : self . is_positive } ;
406+ return SignedBigInt :: < P > {
407+ magnitude : mag,
408+ is_positive : self . is_positive ,
409+ } ;
377410 }
378411 match self . cmp_magnitude_mixed ( rhs) {
379412 Ordering :: Greater | Ordering :: Equal => {
380413 let mag = self . magnitude . sub_trunc :: < M , P > ( & rhs. magnitude ) ;
381- SignedBigInt :: < P > { magnitude : mag, is_positive : self . is_positive }
414+ SignedBigInt :: < P > {
415+ magnitude : mag,
416+ is_positive : self . is_positive ,
417+ }
382418 } ,
383419 Ordering :: Less => {
384420 let mag = rhs. magnitude . sub_trunc :: < N , P > ( & self . magnitude ) ;
385- SignedBigInt :: < P > { magnitude : mag, is_positive : !self . is_positive }
421+ SignedBigInt :: < P > {
422+ magnitude : mag,
423+ is_positive : !self . is_positive ,
424+ }
386425 } ,
387426 }
388427 }
@@ -696,7 +735,11 @@ impl<const N: usize> core::cmp::Ord for SignedBigInt<N> {
696735 ( false , true ) => Ordering :: Less ,
697736 _ => {
698737 let ord = self . magnitude . cmp ( & other. magnitude ) ;
699- if self . is_positive { ord } else { ord. reverse ( ) }
738+ if self . is_positive {
739+ ord
740+ } else {
741+ ord. reverse ( )
742+ }
700743 } ,
701744 }
702745 }
0 commit comments