Sfoglia il codice sorgente

All variants of multiplying BigUint by BigDigit

Allow the multiplication to occur with either operand order and with any
combination of owned and borrowed arguments.
Sam Cappleman-Lynes 8 anni fa
parent
commit
fd2f516a5d
2 ha cambiato i file con 6 aggiunte e 2 eliminazioni
  1. 2 0
      bigint/src/biguint.rs
  2. 4 2
      bigint/src/tests/biguint.rs

+ 2 - 0
bigint/src/biguint.rs

@@ -460,6 +460,8 @@ impl<'a, 'b> Mul<&'b BigUint> for &'a BigUint {
     }
 }
 
+forward_all_scalar_binop_to_val_val!(impl Mul<BigDigit> for BigUint, mul);
+
 impl Mul<BigDigit> for BigUint {
     type Output = BigUint;
 

+ 4 - 2
bigint/src/tests/biguint.rs

@@ -822,13 +822,15 @@ fn test_scalar_mul() {
         if a_vec.len() == 1 {
             let b = BigUint::from_slice(b_vec);
             let a = a_vec[0];
-            assert!(b * a == c);
+            assert_op!(a * b == c);
+            assert_op!(b * a == c);
         }
 
         if b_vec.len() == 1 {
             let a = BigUint::from_slice(a_vec);
             let b = b_vec[0];
-            assert!(a * b == c);
+            assert_op!(a * b == c);
+            assert_op!(b * a == c);
         }
     }
 }