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
|
#[doc(hidden)]
#[macro_export(local_inner_macros)]
macro_rules! _overload_binary {
(+, $($t:tt)+) => (_overload_binary_internal!(Add, add, $($t)+););
(-, $($t:tt)+) => (_overload_binary_internal!(Sub, sub, $($t)+););
(*, $($t:tt)+) => (_overload_binary_internal!(Mul, mul, $($t)+););
(/, $($t:tt)+) => (_overload_binary_internal!(Div, div, $($t)+););
(%, $($t:tt)+) => (_overload_binary_internal!(Rem, rem, $($t)+););
(&, $($t:tt)+) => (_overload_binary_internal!(BitAnd, bitand, $($t)+););
(|, $($t:tt)+) => (_overload_binary_internal!(BitOr, bitor, $($t)+););
(^, $($t:tt)+) => (_overload_binary_internal!(BitXor, bitxor, $($t)+););
(<<, $($t:tt)+) => (_overload_binary_internal!(Shl, shl, $($t)+););
(>>, $($t:tt)+) => (_overload_binary_internal!(Shr, shr, $($t)+););
}
#[doc(hidden)]
#[macro_export(local_inner_macros)]
macro_rules! _overload_binary_internal {
($op_trait:ident, $op_fn:ident, $li:ident, $lt:ty, $ri:ident, $rt:ty, $out:ty, $body:block) => (
impl ops::$op_trait<$rt> for $lt {
type Output = $out;
fn $op_fn(self, $ri: $rt) -> Self::Output {
let $li = self;
$body
}
}
);
}
|