1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#![allow(unused_macros)]
#![allow(unused_imports)]
#![allow(dead_code)]
use once_cell::sync::OnceCell;
pub const VERBOSE_PREFIX: &str = "[verbose]";
static VERBOSE: OnceCell<bool> = OnceCell::new();
#[deny(dead_code)]
pub(in crate) fn verbose_set(verbose: bool) {
VERBOSE.set(verbose).unwrap()
}
pub fn verbose_status() -> bool {
*VERBOSE.get().expect(
"verbose flag was not initialized: \
please set its value using verbose_set( :bool) in main.rs",
)
}
macro_rules! dprint {
($($arg:tt)*) => {
if (cfg!(debug_assertions) || crate::debug_print::verbose_status()) {
print!("{} " crate::debug_print::VERBOSE_PREFIX);
print!($($arg)*);
}
};
}
macro_rules! dprintln {
($($arg:tt)*) => {
if (cfg!(debug_assertions) || crate::debug_print::verbose_status()) {
print!("{} ", crate::debug_print::VERBOSE_PREFIX);
println!($($arg)*);
}
};
}
pub(crate) use dprint;
pub(crate) use dprintln;