bigdecimal/
macros.rs

1// \file src/macros.rs
2//! macros for
3/*
4macro_rules! forward_val_val_binop {
5    (impl $imp:ident for $res:ty, $method:ident) => {
6        impl $imp<$res> for $res {
7            type Output = $res;
8
9            #[inline]
10            fn $method(self, other: $res) -> $res {
11                // forward to val-ref
12                $imp::$method(self, &other)
13            }
14        }
15    };
16}
17
18*/
19macro_rules! forward_ref_val_binop {
20    (impl $imp:ident for $res:ty, $method:ident) => {
21        impl<'a> $imp<$res> for &'a $res {
22            type Output = $res;
23
24            #[inline]
25            fn $method(self, other: $res) -> $res {
26                // forward to ref-ref
27                $imp::$method(self, &other)
28            }
29        }
30    };
31}
32
33/*
34macro_rules! forward_val_ref_binop {
35    (impl $imp:ident for $res:ty, $method:ident) => {
36        impl<'a> $imp<&'a $res> for $res {
37            type Output = $res;
38
39            #[inline]
40            fn $method(self, other: &$res) -> $res {
41                // forward to ref-ref
42                $imp::$method(&self, other)
43            }
44        }
45    };
46}
47
48// Forward everything to ref-ref, when reusing storage is not helpful
49macro_rules! forward_all_binop_to_ref_ref {
50    (impl $imp:ident for $res:ty, $method:ident) => {
51        forward_val_val_binop!(impl $imp for $res, $method);
52        forward_val_ref_binop!(impl $imp for $res, $method);
53        forward_ref_val_binop!(impl $imp for $res, $method);
54    };
55}
56*/
57
58macro_rules! forward_val_assignop {
59    (impl $imp:ident for $res:ty, $method:ident) => {
60        impl $imp<$res> for $res {
61            #[inline]
62            fn $method(&mut self, other: $res) {
63                // forward to mutref-ref
64                $imp::$method(self, &other)
65            }
66        }
67    };
68}