Closed
Description
When print-debugging, I find myself writing println!("{:?}", some expression)
a lot. I wish I didn’t have to write the "{:?}"
part, which is always the same. For temporary debugging-only code, I don’t care about making the output pretty, I only want to see what’s going on.
So I’d like to have a new macro added wherever println!()
is defined:
macro_rules! dump(
($a: expr) => { println!("{:?}", $a) }
($a: expr, $b: expr) => { println!("{:?} {:?}", $a, $b) }
($a: expr, $b: expr, $c: expr) => { println!("{:?} {:?} {:?}", $a, $b, $c) }
($a: expr, $b: expr, $c: expr, $d: expr) => { println!("{:?} {:?} {:?} {:?}", $a, $b, $c, $d) }
)
… with this pattern repeated to however many arguments is appropriate. (Although, worst case, one can always pass a tuple.) Or is there a way to write this completely generic over the number of arguments?