Add a dbg macro to the print utility

This commit is contained in:
Gary Guo 2023-05-07 12:15:37 +01:00
parent 73c9fbf66e
commit dcb6ae6dc1

View File

@ -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)),+,)
};
}