1#[macro_export]
3macro_rules! once {
4 ($expression:expr) => {{
5 use ::core::sync::atomic::{AtomicBool, Ordering};
6
7 static SHOULD_FIRE: AtomicBool = AtomicBool::new(true);
8 if SHOULD_FIRE.swap(false, Ordering::Relaxed) {
9 $expression;
10 }
11 }};
12}
13
14#[macro_export]
18macro_rules! trace_once {
19 ($($arg:tt)+) => ({
20 $crate::once!($crate::tracing::trace!($($arg)+))
21 });
22}
23
24#[macro_export]
28macro_rules! debug_once {
29 ($($arg:tt)+) => ({
30 $crate::once!($crate::tracing::debug!($($arg)+))
31 });
32}
33
34#[macro_export]
38macro_rules! info_once {
39 ($($arg:tt)+) => ({
40 $crate::once!($crate::tracing::info!($($arg)+))
41 });
42}
43
44#[macro_export]
48macro_rules! warn_once {
49 ($($arg:tt)+) => ({
50 $crate::once!($crate::tracing::warn!($($arg)+))
51 });
52}
53
54#[macro_export]
58macro_rules! error_once {
59 ($($arg:tt)+) => ({
60 $crate::once!($crate::tracing::error!($($arg)+))
61 });
62}