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
#[macro_export]
/// Prints the line number and filename to stdout. Additionally, it can accept a string literal and
/// format arguments like the `format!` macro.
#[cfg_attr(docsrs, doc(cfg(feature = "std")))]
macro_rules! here {
    () => {
        println!("{}:{:03}", file!(), line!());
    };
    ($msg:literal) => {
        println!("({}:{:03}): {}", file!(), line!(), $msg);
    };
    ($msg:literal, $($args:expr),+) => {
        println!("({}:{:03}): {}", file!(), line!(), format!($msg, $($args),+));
    }
}

#[macro_export]
/// Prints the line number and filename to stderr. Additionally, it can accept a string literal and
/// format arguments like the `format!` macro.
#[cfg_attr(docsrs, doc(cfg(feature = "std")))]
macro_rules! ehere {
    () => {
        eprintln!("{}:{:03}", file!(), line!());
    };
    ($msg:literal) => {
        eprintln!("({}:{:03}): {}", file!(), line!(), $msg);
    };
    ($msg:literal, $($args:expr),+) => {
        eprintln!("({}:{:03}): {}", file!(), line!(), format!($msg, $($args),+));
    }
}