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
71#[cfg(not(feature = "ferrocene_certified"))]
73macro_rules! impl_fn_for_zst {
74 ($(
75 $( #[$attr: meta] )*
76 struct $Name: ident impl$( <$( $lifetime : lifetime ),+> )? Fn =
77 |$( $arg: ident: $ArgTy: ty ),*| -> $ReturnTy: ty
78 $body: block;
79 )+) => {
80 $(
81 $( #[$attr] )*
82 struct $Name;
83
84 impl $( <$( $lifetime ),+> )? Fn<($( $ArgTy, )*)> for $Name {
85 #[inline]
86 extern "rust-call" fn call(&self, ($( $arg, )*): ($( $ArgTy, )*)) -> $ReturnTy {
87 $body
88 }
89 }
90
91 impl $( <$( $lifetime ),+> )? FnMut<($( $ArgTy, )*)> for $Name {
92 #[inline]
93 extern "rust-call" fn call_mut(
94 &mut self,
95 ($( $arg, )*): ($( $ArgTy, )*)
96 ) -> $ReturnTy {
97 Fn::call(&*self, ($( $arg, )*))
98 }
99 }
100
101 impl $( <$( $lifetime ),+> )? FnOnce<($( $ArgTy, )*)> for $Name {
102 type Output = $ReturnTy;
103
104 #[inline]
105 extern "rust-call" fn call_once(self, ($( $arg, )*): ($( $ArgTy, )*)) -> $ReturnTy {
106 Fn::call(&self, ($( $arg, )*))
107 }
108 }
109 )+
110 }
111}