Rollup merge of #35279 - cengizIO:master, r=brson

Provide a cleaner documentation for 'write!'

Hello!

This is my attempt to fix #35110

Any feedback is more than welcome!

Cheers!
This commit is contained in:
Jonathan Turner 2016-08-11 06:33:57 -07:00 committed by GitHub
commit 476e49614d

View File

@ -229,14 +229,28 @@ macro_rules! try {
})
}
/// Use the `format!` syntax to write data into a buffer.
/// Write formatted data into a buffer
///
/// This macro is typically used with a buffer of `&mut `[`Write`][write].
/// This macro accepts any value with `write_fmt` method as a writer, a format string, and a list
/// of arguments to format.
///
/// `write_fmt` method usually comes from an implementation of [`std::fmt::Write`][fmt_write] or
/// [`std::io::Write`][io_write] traits. These are sometimes called 'writers'.
///
/// Passed arguments will be formatted according to the specified format string and the resulting
/// string will be passed to the writer.
///
/// See [`std::fmt`][fmt] for more information on format syntax.
///
/// Return value is completely dependent on the 'write_fmt' method.
///
/// Common return values are: [`Result`][enum_result], [`io::Result`][type_result]
///
/// [fmt]: ../std/fmt/index.html
/// [write]: ../std/io/trait.Write.html
/// [fmt_write]: ../std/fmt/trait.Write.html
/// [io_write]: ../std/io/trait.Write.html
/// [enum_result]: ../std/result/enum.Result.html
/// [type_result]: ../std/io/type.Result.html
///
/// # Examples
///
@ -255,16 +269,31 @@ macro_rules! write {
($dst:expr, $($arg:tt)*) => ($dst.write_fmt(format_args!($($arg)*)))
}
/// Use the `format!` syntax to write data into a buffer, appending a newline.
/// On all platforms, the newline is the LINE FEED character (`\n`/`U+000A`)
/// alone (no additional CARRIAGE RETURN (`\r`/`U+000D`).
/// Write formatted data into a buffer, with appending a newline.
///
/// This macro is typically used with a buffer of `&mut `[`Write`][write].
/// On all platforms, the newline is the LINE FEED character (`\n`/`U+000A`) alone
/// (no additional CARRIAGE RETURN (`\r`/`U+000D`).
///
/// This macro accepts any value with `write_fmt` method as a writer, a format string, and a list
/// of arguments to format.
///
/// `write_fmt` method usually comes from an implementation of [`std::fmt::Write`][fmt_write] or
/// [`std::io::Write`][io_write] traits. These are sometimes called 'writers'.
///
/// Passed arguments will be formatted according to the specified format string and the resulting
/// string will be passed to the writer.
///
/// See [`std::fmt`][fmt] for more information on format syntax.
///
/// Return value is completely dependent on the 'write_fmt' method.
///
/// Common return values are: [`Result`][enum_result], [`io::Result`][type_result]
///
/// [fmt]: ../std/fmt/index.html
/// [write]: ../std/io/trait.Write.html
/// [fmt_write]: ../std/fmt/trait.Write.html
/// [io_write]: ../std/io/trait.Write.html
/// [enum_result]: ../std/result/enum.Result.html
/// [type_result]: ../std/io/type.Result.html
///
/// # Examples
///