Add a dbg macro to the print utility
This commit is contained in:
parent
73c9fbf66e
commit
dcb6ae6dc1
19
src/print.rs
19
src/print.rs
@ -49,3 +49,22 @@ macro_rules! eprint {
|
||||
let _ = core::write!($crate::print::StderrPrinter, $($arg)*);
|
||||
})
|
||||
}
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! dbg {
|
||||
() => {
|
||||
$crate::eprintln!("[{}:{}]", ::core::file!(), ::core::line!())
|
||||
};
|
||||
($val:expr $(,)?) => {
|
||||
match $val {
|
||||
tmp => {
|
||||
$crate::eprintln!("[{}:{}] {} = {:#?}",
|
||||
::core::file!(), ::core::line!(), ::core::stringify!($val), &tmp);
|
||||
tmp
|
||||
}
|
||||
}
|
||||
};
|
||||
($($val:expr),+ $(,)?) => {
|
||||
($($crate::dbg!($val)),+,)
|
||||
};
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user