dittolive_ditto/utils/
macros.rs

1macro_rules! use_prelude {
2    () => {
3        #[allow(unused_imports)]
4        use crate::utils::prelude::*;
5    };
6}
7
8macro_rules! inlined_modules {(
9    $(
10        $pub:vis
11        mod
12        $module_name:ident
13        ;
14    )*
15) => (
16    $(
17        $pub use self::$module_name::*;
18        mod $module_name;
19    )*
20)}
21
22/// Scoped `use`
23macro_rules! using {
24    (
25        match $expr:tt {
26            use  $($path:tt)::+ ;
27            $($match_body:tt)*
28        }
29    ) => (match $expr { expr => {
30        use  $($path)::+ ;
31        match expr { $($match_body)* }
32    }});
33
34    (
35        match $expr:tt {
36            use $($path:tt)::+ ;
37            $($match_body:tt)*
38        }
39    ) => (match $expr { expr => {
40        use $($path)::+;
41        match expr { $($match_body)* }
42    }});
43
44    (
45        :: $($path:tt)::+ in $($rest:tt)*
46    ) => (
47        const _: () = {
48            use  $($path)::+ ;
49
50            $($rest)*
51        };
52    );
53    (
54        $($path:tt)::+ in $($rest:tt)*
55    ) => (
56        const _: () = {
57            use $($path)::+ ;
58
59            $($rest)*
60        };
61    );
62}
63
64// macro_rules! FIXME {(
65//     $($msg:expr),+ $(; $($body:tt)*)?
66// ) => ({ #[deprecated(note = "FIXME")] struct __; let _ = __; ::tracing::warn!("FIXME: {}",
67//   ::std::format_args!($($msg),*)); $($($body)*)?
68// })}
69
70#[allow(clippy::deprecated_cfg_attr)]
71#[cfg_attr(rustfmt, rustfmt::skip)]
72macro_rules! with_doc {(
73    #[doc = $doc:expr]
74    $item:item
75) => (
76    #[doc = $doc]
77    $item
78)}
79
80macro_rules! trait_alias {(
81    $( #[$attr:meta] )*
82    $pub:vis
83    trait $TraitName:ident = $($super:tt)*
84) => (
85    with_doc! {
86        #[doc = concat!(
87            "An alias for `", stringify!($($super)*), "`."
88        )]
89        $( #[$attr] )*
90        $pub
91        trait $TraitName
92        where
93            Self : $($super)*
94        {}
95    }
96
97    impl<__ : ?Sized> $TraitName for __
98    where
99        Self : $($super)*
100    {}
101)}
102
103#[macro_export]
104macro_rules! event {
105    ( $($input:tt)* ) => {
106        {
107            #![allow(deprecated)]
108            ::tracing::event! { $($input)* }
109        }
110    };
111}
112
113#[macro_export]
114macro_rules! error {
115    ( $($input:tt)* ) => {
116        {
117            #![allow(deprecated)]
118            ::tracing::error! { $($input)* }
119        }
120    };
121}
122
123#[macro_export]
124macro_rules! warn {
125    ( $($input:tt)* ) => {
126        {
127            #![allow(deprecated)]
128            ::tracing::warn! { $($input)* }
129        }
130    };
131}
132
133#[macro_export]
134macro_rules! info {
135    ( $($input:tt)* ) => {
136        {
137            #![allow(deprecated)]
138            ::tracing::info! { $($input)* }
139        }
140    };
141}
142
143#[macro_export]
144macro_rules! debug {
145    ( $($input:tt)* ) => {
146        {
147            #![allow(deprecated)]
148            ::tracing::debug! { $($input)* }
149        }
150    };
151}
152
153#[macro_export]
154macro_rules! trace {
155    ( $($input:tt)* ) => {
156        {
157            #![allow(deprecated)]
158            ::tracing::trace! { $($input)* }
159        }
160    };
161}
162
163#[macro_export]
164macro_rules! span {
165    ( $($input:tt)* ) => {
166        {
167            #![allow(deprecated)]
168            ::tracing::span! { $($input)* }
169        }
170    };
171}
172
173#[macro_export]
174macro_rules! error_span {
175    ( $($input:tt)* ) => {
176        {
177            #![allow(deprecated)]
178            ::tracing::error_span! { $($input)* }
179        }
180    };
181}
182
183#[macro_export]
184macro_rules! warn_span {
185    ( $($input:tt)* ) => {
186        {
187            #![allow(deprecated)]
188            ::tracing::warn_span! { $($input)* }
189        }
190    };
191}
192
193#[macro_export]
194macro_rules! info_span {
195    ( $($input:tt)* ) => {
196        {
197            #![allow(deprecated)]
198            ::tracing::info_span! { $($input)* }
199        }
200    };
201}
202
203#[macro_export]
204macro_rules! debug_span {
205    ( $($input:tt)* ) => {
206        {
207            #![allow(deprecated)]
208            ::tracing::debug_span! { $($input)* }
209        }
210    };
211}
212
213#[macro_export]
214macro_rules! trace_span {
215    ( $($input:tt)* ) => {
216        {
217            #![allow(deprecated)]
218            ::tracing::trace_span! { $($input)* }
219        }
220    };
221}