Skip to content

Commit 8816a9a

Browse files
committed
allow multiple args to dbg!(..)
1 parent 3750348 commit 8816a9a

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/libstd/macros.rs

+10
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,13 @@ macro_rules! eprintln {
314314
/// You can also use `dbg!()` without a value to just print the
315315
/// file and line whenever it's reached.
316316
///
317+
/// Finally, if you want to `dbg!(..)` multiple values, it will treat them as
318+
/// a tuple (and return it, too):
319+
///
320+
/// ```
321+
/// assert_eq!(dbg!(1usize, 2u32), (1, 2));
322+
/// ```
323+
///
317324
/// [stderr]: https://en.wikipedia.org/wiki/Standard_streams#Standard_error_(stderr)
318325
/// [`debug!`]: https://docs.rs/log/*/log/macro.debug.html
319326
/// [`log`]: https://crates.io/crates/log
@@ -333,6 +340,9 @@ macro_rules! dbg {
333340
tmp
334341
}
335342
}
343+
};
344+
($val:expr, $($more:expr),+) => {
345+
dbg!(($val, $($more),*))
336346
}
337347
}
338348

0 commit comments

Comments
 (0)