Rollup merge of #40934 - SamWhited:improve_write_writeln_docs, r=steveklabnik
Improve the docs for the write and writeln macros This change reduces duplication by linking the documentation for `writeln!` to `write!`. It also restructures the `write!` documentation to read in a more logical manner (I hope; feedback would be welcome). Updates #29329, #29381
This commit is contained in:
commit
c34f533a85
1 changed files with 16 additions and 38 deletions
|
@ -337,27 +337,20 @@ macro_rules! try {
|
||||||
|
|
||||||
/// Write formatted data into a buffer
|
/// Write formatted data into a buffer
|
||||||
///
|
///
|
||||||
/// This macro accepts a 'writer' (any value with a `write_fmt` method), a format string, and a
|
/// This macro accepts a format string, a list of arguments, and a 'writer'. Arguments will be
|
||||||
/// list of arguments to format.
|
/// formatted according to the specified format string and the result will be passed to the writer.
|
||||||
|
/// The writer may be any value with a `write_fmt` method; generally this comes from an
|
||||||
|
/// implementation of either the [`std::fmt::Write`] or the [`std::io::Write`] trait. The macro
|
||||||
|
/// returns whatever the 'write_fmt' method returns; commonly a [`std::fmt::Result`], or an
|
||||||
|
/// [`io::Result`].
|
||||||
///
|
///
|
||||||
/// The `write_fmt` method usually comes from an implementation of [`std::fmt::Write`][fmt_write]
|
/// See [`std::fmt`] for more information on the format string syntax.
|
||||||
/// or [`std::io::Write`][io_write] traits. The term 'writer' refers to an implementation of one of
|
|
||||||
/// these two traits.
|
|
||||||
///
|
///
|
||||||
/// Passed arguments will be formatted according to the specified format string and the resulting
|
/// [`std::fmt`]: ../std/fmt/index.html
|
||||||
/// string will be passed to the writer.
|
/// [`std::fmt::Write`]: ../std/fmt/trait.Write.html
|
||||||
///
|
/// [`std::io::Write`]: ../std/io/trait.Write.html
|
||||||
/// See [`std::fmt`][fmt] for more information on format syntax.
|
/// [`std::fmt::Result`]: ../std/fmt/type.Result.html
|
||||||
///
|
/// [`io::Result`]: ../std/io/type.Result.html
|
||||||
/// `write!` returns whatever the 'write_fmt' method returns.
|
|
||||||
///
|
|
||||||
/// Common return values include: [`fmt::Result`][fmt_result], [`io::Result`][io_result]
|
|
||||||
///
|
|
||||||
/// [fmt]: ../std/fmt/index.html
|
|
||||||
/// [fmt_write]: ../std/fmt/trait.Write.html
|
|
||||||
/// [io_write]: ../std/io/trait.Write.html
|
|
||||||
/// [fmt_result]: ../std/fmt/type.Result.html
|
|
||||||
/// [io_result]: ../std/io/type.Result.html
|
|
||||||
///
|
///
|
||||||
/// # Examples
|
/// # Examples
|
||||||
///
|
///
|
||||||
|
@ -396,27 +389,12 @@ macro_rules! write {
|
||||||
/// On all platforms, the newline is the LINE FEED character (`\n`/`U+000A`) alone
|
/// On all platforms, the newline is the LINE FEED character (`\n`/`U+000A`) alone
|
||||||
/// (no additional CARRIAGE RETURN (`\r`/`U+000D`).
|
/// (no additional CARRIAGE RETURN (`\r`/`U+000D`).
|
||||||
///
|
///
|
||||||
/// This macro accepts a 'writer' (any value with a `write_fmt` method), a format string, and a
|
/// For more information, see [`write!`]. For information on the format string syntax, see
|
||||||
/// list of arguments to format.
|
/// [`std::fmt`].
|
||||||
///
|
///
|
||||||
/// The `write_fmt` method usually comes from an implementation of [`std::fmt::Write`][fmt_write]
|
/// [`write!`]: macro.write.html
|
||||||
/// or [`std::io::Write`][io_write] traits. The term 'writer' refers to an implementation of one of
|
/// [`std::fmt`]: ../std/fmt/index.html
|
||||||
/// these two traits.
|
|
||||||
///
|
///
|
||||||
/// Passed arguments will be formatted according to the specified format string and the resulting
|
|
||||||
/// string will be passed to the writer, along with the appended newline.
|
|
||||||
///
|
|
||||||
/// See [`std::fmt`][fmt] for more information on format syntax.
|
|
||||||
///
|
|
||||||
/// `write!` returns whatever the 'write_fmt' method returns.
|
|
||||||
///
|
|
||||||
/// Common return values include: [`fmt::Result`][fmt_result], [`io::Result`][io_result]
|
|
||||||
///
|
|
||||||
/// [fmt]: ../std/fmt/index.html
|
|
||||||
/// [fmt_write]: ../std/fmt/trait.Write.html
|
|
||||||
/// [io_write]: ../std/io/trait.Write.html
|
|
||||||
/// [fmt_result]: ../std/fmt/type.Result.html
|
|
||||||
/// [io_result]: ../std/io/type.Result.html
|
|
||||||
///
|
///
|
||||||
/// # Examples
|
/// # Examples
|
||||||
///
|
///
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue