diff --git a/src/print.rs b/src/print.rs index 26c16a9..fc6d9ac 100644 --- a/src/print.rs +++ b/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)),+,) + }; +}