Auto merge of #28049 - steveklabnik:doc_write, r=alexcrichton

This commit is contained in:
bors 2015-10-09 22:15:24 +00:00
commit 439311d938

View file

@ -168,8 +168,14 @@ macro_rules! try {
}) })
} }
/// Use the `format!` syntax to write data into a buffer of type `&mut Write`. /// Use the `format!` syntax to write data into a buffer.
/// See `std::fmt` for more information. ///
/// 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 /// # Examples
/// ///
@ -179,14 +185,34 @@ macro_rules! try {
/// let mut w = Vec::new(); /// let mut w = Vec::new();
/// write!(&mut w, "test").unwrap(); /// write!(&mut w, "test").unwrap();
/// write!(&mut w, "formatted {}", "arguments").unwrap(); /// write!(&mut w, "formatted {}", "arguments").unwrap();
///
/// assert_eq!(w, b"testformatted arguments");
/// ``` /// ```
#[macro_export] #[macro_export]
macro_rules! write { macro_rules! write {
($dst:expr, $($arg:tt)*) => ($dst.write_fmt(format_args!($($arg)*))) ($dst:expr, $($arg:tt)*) => ($dst.write_fmt(format_args!($($arg)*)))
} }
/// Equivalent to the `write!` macro, except that a newline is appended after /// Use the `format!` syntax to write data into a buffer, appending a newline.
/// the message is written. ///
/// 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] #[macro_export]
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
macro_rules! writeln { macro_rules! writeln {