@@ -1248,7 +1248,7 @@ impl Div<BigUint> for u32 {
1248
1248
#[ inline]
1249
1249
fn div ( self , other : BigUint ) -> BigUint {
1250
1250
match other. data . len ( ) {
1251
- 0 => panic ! ( ) ,
1251
+ 0 => panic ! ( "attempt to divide by zero" ) ,
1252
1252
1 => From :: from ( self as BigDigit / other. data [ 0 ] ) ,
1253
1253
_ => Zero :: zero ( ) ,
1254
1254
}
@@ -1280,7 +1280,7 @@ impl Div<BigUint> for u64 {
1280
1280
#[ inline]
1281
1281
fn div ( self , other : BigUint ) -> BigUint {
1282
1282
match other. data . len ( ) {
1283
- 0 => panic ! ( ) ,
1283
+ 0 => panic ! ( "attempt to divide by zero" ) ,
1284
1284
1 => From :: from ( self / u64:: from ( other. data [ 0 ] ) ) ,
1285
1285
2 => From :: from ( self / big_digit:: to_doublebigdigit ( other. data [ 1 ] , other. data [ 0 ] ) ) ,
1286
1286
_ => Zero :: zero ( ) ,
@@ -1291,7 +1291,7 @@ impl Div<BigUint> for u64 {
1291
1291
#[ inline]
1292
1292
fn div ( self , other : BigUint ) -> BigUint {
1293
1293
match other. data . len ( ) {
1294
- 0 => panic ! ( ) ,
1294
+ 0 => panic ! ( "attempt to divide by zero" ) ,
1295
1295
1 => From :: from ( self / other. data [ 0 ] ) ,
1296
1296
_ => Zero :: zero ( ) ,
1297
1297
}
@@ -1322,7 +1322,7 @@ impl Div<BigUint> for u128 {
1322
1322
#[ inline]
1323
1323
fn div ( self , other : BigUint ) -> BigUint {
1324
1324
match other. data . len ( ) {
1325
- 0 => panic ! ( ) ,
1325
+ 0 => panic ! ( "attempt to divide by zero" ) ,
1326
1326
1 => From :: from ( self / u128:: from ( other. data [ 0 ] ) ) ,
1327
1327
2 => From :: from (
1328
1328
self / u128:: from ( big_digit:: to_doublebigdigit ( other. data [ 1 ] , other. data [ 0 ] ) ) ,
@@ -1339,7 +1339,7 @@ impl Div<BigUint> for u128 {
1339
1339
#[ inline]
1340
1340
fn div ( self , other : BigUint ) -> BigUint {
1341
1341
match other. data . len ( ) {
1342
- 0 => panic ! ( ) ,
1342
+ 0 => panic ! ( "attempt to divide by zero" ) ,
1343
1343
1 => From :: from ( self / other. data [ 0 ] as u128 ) ,
1344
1344
2 => From :: from ( self / big_digit:: to_doublebigdigit ( other. data [ 1 ] , other. data [ 0 ] ) ) ,
1345
1345
_ => Zero :: zero ( ) ,
@@ -1424,7 +1424,7 @@ macro_rules! impl_rem_assign_scalar {
1424
1424
fn rem_assign( & mut self , other: & BigUint ) {
1425
1425
* self = match other. $to_scalar( ) {
1426
1426
None => * self ,
1427
- Some ( 0 ) => panic!( ) ,
1427
+ Some ( 0 ) => panic!( "attempt to divide by zero" ) ,
1428
1428
Some ( v) => * self % v
1429
1429
} ;
1430
1430
}
@@ -2686,7 +2686,10 @@ impl BigUint {
2686
2686
///
2687
2687
/// Panics if the modulus is zero.
2688
2688
pub fn modpow ( & self , exponent : & Self , modulus : & Self ) -> Self {
2689
- assert ! ( !modulus. is_zero( ) , "divide by zero!" ) ;
2689
+ assert ! (
2690
+ !modulus. is_zero( ) ,
2691
+ "attempt to calculate with zero modulus!"
2692
+ ) ;
2690
2693
2691
2694
if modulus. is_odd ( ) {
2692
2695
// For an odd modulus, we can use Montgomery multiplication in base 2^32.
@@ -2725,7 +2728,10 @@ impl BigUint {
2725
2728
}
2726
2729
2727
2730
fn plain_modpow ( base : & BigUint , exp_data : & [ BigDigit ] , modulus : & BigUint ) -> BigUint {
2728
- assert ! ( !modulus. is_zero( ) , "divide by zero!" ) ;
2731
+ assert ! (
2732
+ !modulus. is_zero( ) ,
2733
+ "attempt to calculate with zero modulus!"
2734
+ ) ;
2729
2735
2730
2736
let i = match exp_data. iter ( ) . position ( |& r| r != 0 ) {
2731
2737
None => return BigUint :: one ( ) ,
0 commit comments