about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2015-10-09 22:15:24 +0000
committerbors <bors@rust-lang.org>2015-10-09 22:15:24 +0000
commit439311d9382abd5d22c9068f3f158d3b9ef6d1c9 (patch)
tree83781a7b464ab6e7a80f0f7898dc1fd5521fe343
parent7dcc4d7dcbc7980969264a35b58cf6167df0fd7a (diff)
parentef9e542b453023a0cb6cd0855f5d1214f0024a88 (diff)
downloadrust-439311d9382abd5d22c9068f3f158d3b9ef6d1c9.tar.gz
rust-439311d9382abd5d22c9068f3f158d3b9ef6d1c9.zip
Auto merge of #28049 - steveklabnik:doc_write, r=alexcrichton
-rw-r--r--src/libcore/macros.rs34
1 files changed, 30 insertions, 4 deletions
diff --git a/src/libcore/macros.rs b/src/libcore/macros.rs
index 25ca33a3d50..58e0bb37b0a 100644
--- a/src/libcore/macros.rs
+++ b/src/libcore/macros.rs
@@ -168,8 +168,14 @@ macro_rules! try {
     })
 }
 
-/// Use the `format!` syntax to write data into a buffer of type `&mut Write`.
-/// See `std::fmt` for more information.
+/// Use the `format!` syntax to write data into a buffer.
+///
+/// This macro is typically used with a buffer of `&mut `[`Write`][write].
+///
+/// See [`std::fmt`][fmt] for more information on format syntax.
+///
+/// [fmt]: fmt/index.html
+/// [write]: io/trait.Write.html
 ///
 /// # Examples
 ///
@@ -179,14 +185,34 @@ macro_rules! try {
 /// let mut w = Vec::new();
 /// write!(&mut w, "test").unwrap();
 /// write!(&mut w, "formatted {}", "arguments").unwrap();
+///
+/// assert_eq!(w, b"testformatted arguments");
 /// ```
 #[macro_export]
 macro_rules! write {
     ($dst:expr, $($arg:tt)*) => ($dst.write_fmt(format_args!($($arg)*)))
 }
 
-/// Equivalent to the `write!` macro, except that a newline is appended after
-/// the message is written.
+/// Use the `format!` syntax to write data into a buffer, appending a newline.
+///
+/// This macro is typically used with a buffer of `&mut `[`Write`][write].
+///
+/// See [`std::fmt`][fmt] for more information on format syntax.
+///
+/// [fmt]: fmt/index.html
+/// [write]: io/trait.Write.html
+///
+/// # Examples
+///
+/// ```
+/// use std::io::Write;
+///
+/// let mut w = Vec::new();
+/// writeln!(&mut w, "test").unwrap();
+/// writeln!(&mut w, "formatted {}", "arguments").unwrap();
+///
+/// assert_eq!(&w[..], "test\nformatted arguments\n".as_bytes());
+/// ```
 #[macro_export]
 #[stable(feature = "rust1", since = "1.0.0")]
 macro_rules! writeln {