]> git.lizzy.rs Git - rust.git/commitdiff
allow multiple args to `dbg!(..)`
authorAndre Bogus <bogusandre@gmail.com>
Tue, 9 Apr 2019 21:00:23 +0000 (23:00 +0200)
committerAndre Bogus <bogusandre@gmail.com>
Wed, 10 Apr 2019 03:43:31 +0000 (05:43 +0200)
src/libstd/macros.rs

index 14b266a43441db7195ede939d453834c6a757633..c1cd6b8429b5c522e20025d255aad816c23d41d1 100644 (file)
@@ -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),*))
     }
 }