feat(dbg): lift the latest version

Signed-off-by: Anhad Singh <andypython@protonmail.com>
This commit is contained in:
Anhad Singh
2024-12-10 22:12:47 +11:00
parent de00d6c6b9
commit 064c7c31c5
+10 -2
View File
@@ -45,8 +45,12 @@ macro_rules! eprintln {
/// Lifted from libstd
#[macro_export]
macro_rules! dbg {
// NOTE: We cannot use `concat!` to make a static string as a format argument
// of `eprintln!` because `file!` could contain a `{` or
// `$val` expression could be a block (`{ .. }`), in which case the `eprintln!`
// will be malformed.
() => {
eprintln!("[{}:{}]", file!(), line!());
eprintln!("[{}:{}:{}]", file!(), line!(), column!());
};
($val:expr) => {
// Use of `match` here is intentional because it affects the lifetimes
@@ -54,9 +58,10 @@ macro_rules! dbg {
match $val {
tmp => {
eprintln!(
"[{}:{}] {} = {:#?}",
"[{}:{}:{}] {} = {:#?}",
file!(),
line!(),
column!(),
stringify!($val),
&tmp
);
@@ -64,6 +69,9 @@ macro_rules! dbg {
}
}
};
($($val:expr),+ $(,)?) => {
($(dbg!($val)),+,)
};
}
#[macro_export]