feat(dbg): lift the latest version
Signed-off-by: Anhad Singh <andypython@protonmail.com>
This commit is contained in:
+10
-2
@@ -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]
|
||||
|
||||
Reference in New Issue
Block a user