endian_num/
internal_macros.rs1macro_rules! forward_ref_unop {
6 (impl $Trait:ident, $method:ident for $T:ty) => {
7 impl $Trait for &$T {
8 type Output = <$T as $Trait>::Output;
9
10 #[inline]
11 #[track_caller]
12 fn $method(self) -> <$T as $Trait>::Output {
13 $Trait::$method(*self)
14 }
15 }
16 };
17}
18
19macro_rules! forward_ref_binop {
22 (impl $Trait:ident<$Rhs:ty>, $method:ident for $T:ty) => {
23 impl<'a> $Trait<$Rhs> for &'a $T {
24 type Output = <$T as $Trait<$Rhs>>::Output;
25
26 #[inline]
27 #[track_caller]
28 fn $method(self, rhs: $Rhs) -> <$T as $Trait<$Rhs>>::Output {
29 $Trait::$method(*self, rhs)
30 }
31 }
32
33 impl $Trait<&$Rhs> for $T {
34 type Output = <$T as $Trait<$Rhs>>::Output;
35
36 #[inline]
37 #[track_caller]
38 fn $method(self, rhs: &$Rhs) -> <$T as $Trait<$Rhs>>::Output {
39 $Trait::$method(self, *rhs)
40 }
41 }
42
43 impl $Trait<&$Rhs> for &$T {
44 type Output = <$T as $Trait<$Rhs>>::Output;
45
46 #[inline]
47 #[track_caller]
48 fn $method(self, rhs: &$Rhs) -> <$T as $Trait<$Rhs>>::Output {
49 $Trait::$method(*self, *rhs)
50 }
51 }
52 };
53}
54
55macro_rules! forward_ref_op_assign {
58 (impl $Trait:ident<$Rhs:ty>, $method:ident for $T:ty) => {
59 impl $Trait<&$Rhs> for $T {
60 #[inline]
61 #[track_caller]
62 fn $method(&mut self, rhs: &$Rhs) {
63 $Trait::$method(self, *rhs);
64 }
65 }
66 };
67}