summaryrefslogtreecommitdiffstats
path: root/vendor/overload/src/binary.rs
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/overload/src/binary.rs')
-rw-r--r--vendor/overload/src/binary.rs28
1 files changed, 28 insertions, 0 deletions
diff --git a/vendor/overload/src/binary.rs b/vendor/overload/src/binary.rs
new file mode 100644
index 000000000..b4c781bff
--- /dev/null
+++ b/vendor/overload/src/binary.rs
@@ -0,0 +1,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
+ }
+ }
+ );
+}