dittolive_ditto/utils/
macros.rs

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