solana_zk_token_sdk/
macros.rs1#[macro_export]
3macro_rules! define_add_variants {
4 (LHS = $lhs:ty, RHS = $rhs:ty, Output = $out:ty) => {
5 impl<'b> Add<&'b $rhs> for $lhs {
6 type Output = $out;
7 fn add(self, rhs: &'b $rhs) -> $out {
8 &self + rhs
9 }
10 }
11
12 impl<'a> Add<$rhs> for &'a $lhs {
13 type Output = $out;
14 fn add(self, rhs: $rhs) -> $out {
15 self + &rhs
16 }
17 }
18
19 impl Add<$rhs> for $lhs {
20 type Output = $out;
21 fn add(self, rhs: $rhs) -> $out {
22 &self + &rhs
23 }
24 }
25 };
26}
27
28macro_rules! define_sub_variants {
29 (LHS = $lhs:ty, RHS = $rhs:ty, Output = $out:ty) => {
30 impl<'b> Sub<&'b $rhs> for $lhs {
31 type Output = $out;
32 fn sub(self, rhs: &'b $rhs) -> $out {
33 &self - rhs
34 }
35 }
36
37 impl<'a> Sub<$rhs> for &'a $lhs {
38 type Output = $out;
39 fn sub(self, rhs: $rhs) -> $out {
40 self - &rhs
41 }
42 }
43
44 impl Sub<$rhs> for $lhs {
45 type Output = $out;
46 fn sub(self, rhs: $rhs) -> $out {
47 &self - &rhs
48 }
49 }
50 };
51}
52
53macro_rules! define_mul_variants {
54 (LHS = $lhs:ty, RHS = $rhs:ty, Output = $out:ty) => {
55 impl<'b> Mul<&'b $rhs> for $lhs {
56 type Output = $out;
57 fn mul(self, rhs: &'b $rhs) -> $out {
58 &self * rhs
59 }
60 }
61
62 impl<'a> Mul<$rhs> for &'a $lhs {
63 type Output = $out;
64 fn mul(self, rhs: $rhs) -> $out {
65 self * &rhs
66 }
67 }
68
69 impl Mul<$rhs> for $lhs {
70 type Output = $out;
71 fn mul(self, rhs: $rhs) -> $out {
72 &self * &rhs
73 }
74 }
75 };
76}