1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
use core::ops::{Mul, MulAssign};

use num_bigint::BigUint;

use super::Ex3Uint;

#[macro_export(local_inner_macros)]
macro_rules! impl_mul_uint_for {
  ($for_type:ty, $($t:ty),*) => {
    $(
      impl Mul<$t> for $for_type {
        type Output = $for_type;

        fn mul(mut self, rhs: $t) -> Self::Output {
          self *= rhs;
          self
        }
      }
    )*
  };
}

#[macro_export(local_inner_macros)]
macro_rules! impl_mul_assign_uint_for {
  ($for_type:ty, $($t:ty),*) => {
    $(
      impl MulAssign<$t> for $for_type {
        fn mul_assign(&mut self, rhs: $t) {
          self.0 *= rhs;
        }
      }
    )*
  };
}

impl_mul_uint_for!(Ex3Uint, u8, u16, u32, u64, u128, usize, BigUint);
impl_mul_assign_uint_for!(Ex3Uint, u8, u16, u32, u64, u128, usize, BigUint);