From b7724a665075e099ad4ee3a741635bfb6e78cb83 Mon Sep 17 00:00:00 2001 From: Josh Stone Date: Tue, 15 Dec 2015 22:06:59 -0800 Subject: [PATCH] Simplify BigInt Mul forwarding --- src/bigint.rs | 38 +++----------------------------------- 1 file changed, 3 insertions(+), 35 deletions(-) diff --git a/src/bigint.rs b/src/bigint.rs index fce68e0..32c184f 100644 --- a/src/bigint.rs +++ b/src/bigint.rs @@ -1950,47 +1950,15 @@ impl Sub for BigInt { } } -// We want to forward to BigUint::mul, and defer the val/ref decision to -// BigUint, so we duplicate this body for every val/ref combination. -macro_rules! bigint_mul { - ($a:expr, $a_data:expr, $b:expr, $b_data:expr) => { - BigInt::from_biguint($a.sign * $b.sign, $a_data * $b_data) - }; -} +forward_all_binop_to_ref_ref!(impl Mul for BigInt, mul); impl<'a, 'b> Mul<&'b BigInt> for &'a BigInt { type Output = BigInt; #[inline] fn mul(self, other: &BigInt) -> BigInt { - bigint_mul!(self, &self.data, other, &other.data) - } -} - -impl<'a> Mul for &'a BigInt { - type Output = BigInt; - - #[inline] - fn mul(self, other: BigInt) -> BigInt { - bigint_mul!(self, &self.data, other, other.data) - } -} - -impl<'a> Mul<&'a BigInt> for BigInt { - type Output = BigInt; - - #[inline] - fn mul(self, other: &BigInt) -> BigInt { - bigint_mul!(self, self.data, other, &other.data) - } -} - -impl Mul for BigInt { - type Output = BigInt; - - #[inline] - fn mul(self, other: BigInt) -> BigInt { - bigint_mul!(self, self.data, other, other.data) + BigInt::from_biguint(self.sign * other.sign, + &self.data * &other.data) } }