Skip to content

Commit 96c39d2

Browse files
authored
Rollup merge of rust-lang#35279 - cengizIO:master, r=brson
Provide a cleaner documentation for 'write!' Hello! This is my attempt to fix rust-lang#35110 Any feedback is more than welcome! Cheers!
2 parents ae77410 + c630bea commit 96c39d2

File tree

1 file changed

+37
-8
lines changed

1 file changed

+37
-8
lines changed

src/libcore/macros.rs

Lines changed: 37 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -229,14 +229,28 @@ macro_rules! try {
229229
})
230230
}
231231

232-
/// Use the `format!` syntax to write data into a buffer.
232+
/// Write formatted data into a buffer
233233
///
234-
/// This macro is typically used with a buffer of `&mut `[`Write`][write].
234+
/// This macro accepts any value with `write_fmt` method as a writer, a format string, and a list
235+
/// of arguments to format.
236+
///
237+
/// `write_fmt` method usually comes from an implementation of [`std::fmt::Write`][fmt_write] or
238+
/// [`std::io::Write`][io_write] traits. These are sometimes called 'writers'.
239+
///
240+
/// Passed arguments will be formatted according to the specified format string and the resulting
241+
/// string will be passed to the writer.
235242
///
236243
/// See [`std::fmt`][fmt] for more information on format syntax.
237244
///
245+
/// Return value is completely dependent on the 'write_fmt' method.
246+
///
247+
/// Common return values are: [`Result`][enum_result], [`io::Result`][type_result]
248+
///
238249
/// [fmt]: ../std/fmt/index.html
239-
/// [write]: ../std/io/trait.Write.html
250+
/// [fmt_write]: ../std/fmt/trait.Write.html
251+
/// [io_write]: ../std/io/trait.Write.html
252+
/// [enum_result]: ../std/result/enum.Result.html
253+
/// [type_result]: ../std/io/type.Result.html
240254
///
241255
/// # Examples
242256
///
@@ -255,16 +269,31 @@ macro_rules! write {
255269
($dst:expr, $($arg:tt)*) => ($dst.write_fmt(format_args!($($arg)*)))
256270
}
257271

258-
/// Use the `format!` syntax to write data into a buffer, appending a newline.
259-
/// On all platforms, the newline is the LINE FEED character (`\n`/`U+000A`)
260-
/// alone (no additional CARRIAGE RETURN (`\r`/`U+000D`).
272+
/// Write formatted data into a buffer, with appending a newline.
273+
///
274+
/// On all platforms, the newline is the LINE FEED character (`\n`/`U+000A`) alone
275+
/// (no additional CARRIAGE RETURN (`\r`/`U+000D`).
261276
///
262-
/// This macro is typically used with a buffer of `&mut `[`Write`][write].
277+
/// This macro accepts any value with `write_fmt` method as a writer, a format string, and a list
278+
/// of arguments to format.
279+
///
280+
/// `write_fmt` method usually comes from an implementation of [`std::fmt::Write`][fmt_write] or
281+
/// [`std::io::Write`][io_write] traits. These are sometimes called 'writers'.
282+
///
283+
/// Passed arguments will be formatted according to the specified format string and the resulting
284+
/// string will be passed to the writer.
263285
///
264286
/// See [`std::fmt`][fmt] for more information on format syntax.
265287
///
288+
/// Return value is completely dependent on the 'write_fmt' method.
289+
///
290+
/// Common return values are: [`Result`][enum_result], [`io::Result`][type_result]
291+
///
266292
/// [fmt]: ../std/fmt/index.html
267-
/// [write]: ../std/io/trait.Write.html
293+
/// [fmt_write]: ../std/fmt/trait.Write.html
294+
/// [io_write]: ../std/io/trait.Write.html
295+
/// [enum_result]: ../std/result/enum.Result.html
296+
/// [type_result]: ../std/io/type.Result.html
268297
///
269298
/// # Examples
270299
///

0 commit comments

Comments
 (0)