diff options
| author | bors <bors@rust-lang.org> | 2017-01-07 10:59:46 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2017-01-07 10:59:46 +0000 |
| commit | e1dfe3d678de05f0e5b5f1bfa9c06025a7a0fb37 (patch) | |
| tree | 78044fa104e6a230f2f0078805d99cb87c791c00 | |
| parent | b9637f79e261d0b90d23bdbce6b0a16d42868bdd (diff) | |
| parent | a0b346a34936c6ed88ad9680069c0300b0c068d8 (diff) | |
| download | rust-e1dfe3d678de05f0e5b5f1bfa9c06025a7a0fb37.tar.gz rust-e1dfe3d678de05f0e5b5f1bfa9c06025a7a0fb37.zip | |
Auto merge of #38469 - tbu-:pr_writeln_no_args, r=brson
Allow `writeln!` without arguments, in symmetry with `println!` CC #36825.
| -rw-r--r-- | src/libcore/macros.rs | 6 | ||||
| -rw-r--r-- | src/libstd/macros.rs | 2 |
2 files changed, 6 insertions, 2 deletions
diff --git a/src/libcore/macros.rs b/src/libcore/macros.rs index b3f5363f5b1..ba52edb1ae8 100644 --- a/src/libcore/macros.rs +++ b/src/libcore/macros.rs @@ -404,10 +404,11 @@ macro_rules! write { /// use std::io::Write; /// /// let mut w = Vec::new(); +/// writeln!(&mut w).unwrap(); /// writeln!(&mut w, "test").unwrap(); /// writeln!(&mut w, "formatted {}", "arguments").unwrap(); /// -/// assert_eq!(&w[..], "test\nformatted arguments\n".as_bytes()); +/// assert_eq!(&w[..], "\ntest\nformatted arguments\n".as_bytes()); /// ``` /// /// A module can import both `std::fmt::Write` and `std::io::Write` and call `write!` on objects @@ -427,6 +428,9 @@ macro_rules! write { #[macro_export] #[stable(feature = "rust1", since = "1.0.0")] macro_rules! writeln { + ($dst:expr) => ( + write!($dst, "\n") + ); ($dst:expr, $fmt:expr) => ( write!($dst, concat!($fmt, "\n")) ); diff --git a/src/libstd/macros.rs b/src/libstd/macros.rs index 0ce6b0a9431..52c6da58151 100644 --- a/src/libstd/macros.rs +++ b/src/libstd/macros.rs @@ -112,7 +112,7 @@ macro_rules! print { /// # Examples /// /// ``` -/// println!(); +/// println!(); // prints just a newline /// println!("hello there!"); /// println!("format {} arguments", "some"); /// ``` |
