Skip to content

Commit

Permalink
Rollup merge of rust-lang#35279 - cengizIO:master, r=brson
Browse files Browse the repository at this point in the history
Provide a cleaner documentation for 'write!'

Hello!

This is my attempt to fix rust-lang#35110

Any feedback is more than welcome!

Cheers!
  • Loading branch information
Jonathan Turner committed Aug 10, 2016
2 parents 1f2ae38 + c630bea commit 56cc1fc
Showing 1 changed file with 37 additions and 8 deletions.
45 changes: 37 additions & 8 deletions src/libcore/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
///
Expand All @@ -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.
///
/// On all platforms, the newline is the LINE FEED character (`\n`/`U+000A`) alone
/// (no additional CARRIAGE RETURN (`\r`/`U+000D`).
///
/// 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
///
Expand Down

0 comments on commit 56cc1fc

Please sign in to comment.