diff options
| author | Andre Bogus <bogusandre@gmail.com> | 2019-04-09 23:00:23 +0200 |
|---|---|---|
| committer | Andre Bogus <bogusandre@gmail.com> | 2019-04-10 05:43:31 +0200 |
| commit | 8816a9ac1fbb2c35128ab2e1e3fd1032178bacc3 (patch) | |
| tree | 9a1865ecc0e02acb3f564103707c4b7fb6f0ef5e /src/libstd | |
| parent | 3750348daff89741e3153e0e120aa70a45ff5b68 (diff) | |
| download | rust-8816a9ac1fbb2c35128ab2e1e3fd1032178bacc3.tar.gz rust-8816a9ac1fbb2c35128ab2e1e3fd1032178bacc3.zip | |
allow multiple args to `dbg!(..)`
Diffstat (limited to 'src/libstd')
| -rw-r--r-- | src/libstd/macros.rs | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/libstd/macros.rs b/src/libstd/macros.rs index 14b266a4344..c1cd6b8429b 100644 --- a/src/libstd/macros.rs +++ b/src/libstd/macros.rs @@ -314,6 +314,13 @@ macro_rules! eprintln { /// You can also use `dbg!()` without a value to just print the /// file and line whenever it's reached. /// +/// Finally, if you want to `dbg!(..)` multiple values, it will treat them as +/// a tuple (and return it, too): +/// +/// ``` +/// assert_eq!(dbg!(1usize, 2u32), (1, 2)); +/// ``` +/// /// [stderr]: https://en.wikipedia.org/wiki/Standard_streams#Standard_error_(stderr) /// [`debug!`]: https://docs.rs/log/*/log/macro.debug.html /// [`log`]: https://crates.io/crates/log @@ -333,6 +340,9 @@ macro_rules! dbg { tmp } } + }; + ($val:expr, $($more:expr),+) => { + dbg!(($val, $($more),*)) } } |
