1macro_rules! forward_ref_unop {
4 (impl $imp:ident, $method:ident for $t:ty, $(#[$attr:meta])+) => {
5 $(#[$attr])+
6 impl const $imp for &$t {
7 type Output = <$t as $imp>::Output;
8
9 #[inline]
10 fn $method(self) -> <$t as $imp>::Output {
11 $imp::$method(*self)
12 }
13 }
14 }
15}
16
17macro_rules! forward_ref_binop {
20 (impl $imp:ident, $method:ident for $t:ty, $u:ty, $(#[$attr:meta])+) => {
21 $(#[$attr])+
22 impl const $imp<$u> for &$t {
23 type Output = <$t as $imp<$u>>::Output;
24
25 #[inline]
26 #[track_caller]
27 fn $method(self, other: $u) -> <$t as $imp<$u>>::Output {
28 $imp::$method(*self, other)
29 }
30 }
31
32 $(#[$attr])+
33 impl const $imp<&$u> for $t {
34 type Output = <$t as $imp<$u>>::Output;
35
36 #[inline]
37 #[track_caller]
38 fn $method(self, other: &$u) -> <$t as $imp<$u>>::Output {
39 $imp::$method(self, *other)
40 }
41 }
42
43 $(#[$attr])+
44 impl const $imp<&$u> for &$t {
45 type Output = <$t as $imp<$u>>::Output;
46
47 #[inline]
48 #[track_caller]
49 fn $method(self, other: &$u) -> <$t as $imp<$u>>::Output {
50 $imp::$method(*self, *other)
51 }
52 }
53 }
54}
55
56macro_rules! forward_ref_op_assign {
59 (impl $imp:ident, $method:ident for $t:ty, $u:ty, $(#[$attr:meta])+) => {
60 $(#[$attr])+
61 impl const $imp<&$u> for $t {
62 #[inline]
63 #[track_caller]
64 fn $method(&mut self, other: &$u) {
65 $imp::$method(self, *other);
66 }
67 }
68 }
69}
70
71macro_rules! impl_fn_for_zst {
73 ($(
74 $( #[$attr: meta] )*
75 struct $Name: ident impl$( <$( $lifetime : lifetime ),+> )? Fn =
76 |$( $arg: ident: $ArgTy: ty ),*| -> $ReturnTy: ty
77 $body: block;
78 )+) => {
79 $(
80 $( #[$attr] )*
81 struct $Name;
82
83 impl $( <$( $lifetime ),+> )? Fn<($( $ArgTy, )*)> for $Name {
84 #[inline]
85 extern "rust-call" fn call(&self, ($( $arg, )*): ($( $ArgTy, )*)) -> $ReturnTy {
86 $body
87 }
88 }
89
90 impl $( <$( $lifetime ),+> )? FnMut<($( $ArgTy, )*)> for $Name {
91 #[inline]
92 extern "rust-call" fn call_mut(
93 &mut self,
94 ($( $arg, )*): ($( $ArgTy, )*)
95 ) -> $ReturnTy {
96 Fn::call(&*self, ($( $arg, )*))
97 }
98 }
99
100 impl $( <$( $lifetime ),+> )? FnOnce<($( $ArgTy, )*)> for $Name {
101 type Output = $ReturnTy;
102
103 #[inline]
104 extern "rust-call" fn call_once(self, ($( $arg, )*): ($( $ArgTy, )*)) -> $ReturnTy {
105 Fn::call(&self, ($( $arg, )*))
106 }
107 }
108 )+
109 }
110}