curve25519_dalek/
macros.rs1macro_rules! define_add_variants {
16 (LHS = $lhs:ty, RHS = $rhs:ty, Output = $out:ty) => {
17 impl<'b> Add<&'b $rhs> for $lhs {
18 type Output = $out;
19 fn add(self, rhs: &'b $rhs) -> $out {
20 &self + rhs
21 }
22 }
23
24 impl<'a> Add<$rhs> for &'a $lhs {
25 type Output = $out;
26 fn add(self, rhs: $rhs) -> $out {
27 self + &rhs
28 }
29 }
30
31 impl Add<$rhs> for $lhs {
32 type Output = $out;
33 fn add(self, rhs: $rhs) -> $out {
34 &self + &rhs
35 }
36 }
37 };
38}
39
40macro_rules! define_add_assign_variants {
42 (LHS = $lhs:ty, RHS = $rhs:ty) => {
43 impl AddAssign<$rhs> for $lhs {
44 fn add_assign(&mut self, rhs: $rhs) {
45 *self += &rhs;
46 }
47 }
48 };
49}
50
51macro_rules! define_sub_variants {
53 (LHS = $lhs:ty, RHS = $rhs:ty, Output = $out:ty) => {
54 impl<'b> Sub<&'b $rhs> for $lhs {
55 type Output = $out;
56 fn sub(self, rhs: &'b $rhs) -> $out {
57 &self - rhs
58 }
59 }
60
61 impl<'a> Sub<$rhs> for &'a $lhs {
62 type Output = $out;
63 fn sub(self, rhs: $rhs) -> $out {
64 self - &rhs
65 }
66 }
67
68 impl Sub<$rhs> for $lhs {
69 type Output = $out;
70 fn sub(self, rhs: $rhs) -> $out {
71 &self - &rhs
72 }
73 }
74 };
75}
76
77macro_rules! define_sub_assign_variants {
79 (LHS = $lhs:ty, RHS = $rhs:ty) => {
80 impl SubAssign<$rhs> for $lhs {
81 fn sub_assign(&mut self, rhs: $rhs) {
82 *self -= &rhs;
83 }
84 }
85 };
86}
87
88macro_rules! define_mul_variants {
90 (LHS = $lhs:ty, RHS = $rhs:ty, Output = $out:ty) => {
91 impl<'b> Mul<&'b $rhs> for $lhs {
92 type Output = $out;
93 fn mul(self, rhs: &'b $rhs) -> $out {
94 &self * rhs
95 }
96 }
97
98 impl<'a> Mul<$rhs> for &'a $lhs {
99 type Output = $out;
100 fn mul(self, rhs: $rhs) -> $out {
101 self * &rhs
102 }
103 }
104
105 impl Mul<$rhs> for $lhs {
106 type Output = $out;
107 fn mul(self, rhs: $rhs) -> $out {
108 &self * &rhs
109 }
110 }
111 };
112}
113
114macro_rules! define_mul_assign_variants {
116 (LHS = $lhs:ty, RHS = $rhs:ty) => {
117 impl MulAssign<$rhs> for $lhs {
118 fn mul_assign(&mut self, rhs: $rhs) {
119 *self *= &rhs;
120 }
121 }
122 };
123}