1#[doc(hidden)]
2#[macro_export(local_inner_macros)]
3macro_rules! _overload_binary {
4 (+, $($t:tt)+) => (_overload_binary_internal!(Add, add, $($t)+););
5 (-, $($t:tt)+) => (_overload_binary_internal!(Sub, sub, $($t)+););
6 (*, $($t:tt)+) => (_overload_binary_internal!(Mul, mul, $($t)+););
7 (/, $($t:tt)+) => (_overload_binary_internal!(Div, div, $($t)+););
8 (%, $($t:tt)+) => (_overload_binary_internal!(Rem, rem, $($t)+););
9 (&, $($t:tt)+) => (_overload_binary_internal!(BitAnd, bitand, $($t)+););
10 (|, $($t:tt)+) => (_overload_binary_internal!(BitOr, bitor, $($t)+););
11 (^, $($t:tt)+) => (_overload_binary_internal!(BitXor, bitxor, $($t)+););
12 (<<, $($t:tt)+) => (_overload_binary_internal!(Shl, shl, $($t)+););
13 (>>, $($t:tt)+) => (_overload_binary_internal!(Shr, shr, $($t)+););
14}
15
16#[doc(hidden)]
17#[macro_export(local_inner_macros)]
18macro_rules! _overload_binary_internal {
19 ($op_trait:ident, $op_fn:ident, $li:ident, $lt:ty, $ri:ident, $rt:ty, $out:ty, $body:block) => (
20 impl ops::$op_trait<$rt> for $lt {
21 type Output = $out;
22 fn $op_fn(self, $ri: $rt) -> Self::Output {
23 let $li = self;
24 $body
25 }
26 }
27 );
28}
29