Skip to content

Commit 15be66d

Browse files
author
Cengiz Can
committed
Provide a cleaner documentation for 'write!'
1 parent a0b4e67 commit 15be66d

File tree

1 file changed

+31
-6
lines changed

1 file changed

+31
-6
lines changed

src/libcore/macros.rs

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

232-
/// Use the `format!` syntax to write data into a buffer.
232+
/// Calls `write_fmt` function on a writer
233233
///
234-
/// This macro is typically used with a buffer of `&mut `[`Write`][write].
234+
/// This macro takes an implementer of [`std::fmt::Write`][fmt_write] or
235+
/// [`std::io::Write`][io_write] trait, a precompiled format string, and a list of arguments.
236+
///
237+
/// Implementors of the `Write` trait are sometimes called 'writers'.
238+
///
239+
/// These arguments will be formatted according to the specified format string and
240+
/// the resulting string will be passed to the writer.
241+
///
242+
/// Return value is either [`Result`][enum_result] or [`io::Result`][type_result] depending on
243+
/// the writer.
235244
///
236245
/// See [`std::fmt`][fmt] for more information on format syntax.
237246
///
238247
/// [fmt]: ../std/fmt/index.html
239-
/// [write]: ../std/io/trait.Write.html
248+
/// [fmt_write]: ../std/fmt/trait.Write.html
249+
/// [io_write]: ../std/io/trait.Write.html
250+
/// [enum_result]: ../std/result/enum.Result.html
251+
/// [type_result]: ../std/io/type.Result.html
240252
///
241253
/// # Examples
242254
///
@@ -255,16 +267,29 @@ macro_rules! write {
255267
($dst:expr, $($arg:tt)*) => ($dst.write_fmt(format_args!($($arg)*)))
256268
}
257269

258-
/// Use the `format!` syntax to write data into a buffer, appending a newline.
270+
/// Calls `write_fmt` function on a writer, with appending a newline.
271+
///
259272
/// On all platforms, the newline is the LINE FEED character (`\n`/`U+000A`)
260273
/// alone (no additional CARRIAGE RETURN (`\r`/`U+000D`).
261274
///
262-
/// This macro is typically used with a buffer of `&mut `[`Write`][write].
275+
/// This macro takes an implementer of [`std::fmt::Write`][fmt_write] or
276+
/// [`std::io::Write`][io_write] trait, a precompiled format string, and a list of arguments.
277+
///
278+
/// Implementors of the `Write` trait are sometimes called 'writers'.
279+
///
280+
/// These arguments will be formatted according to the specified format string and
281+
/// the resulting string will be passed to the writer.
282+
///
283+
/// Return value is either [`Result`][enum_result] or [`io::Result`][type_result] depending on
284+
/// the writer.
263285
///
264286
/// See [`std::fmt`][fmt] for more information on format syntax.
265287
///
266288
/// [fmt]: ../std/fmt/index.html
267-
/// [write]: ../std/io/trait.Write.html
289+
/// [fmt_write]: ../std/fmt/trait.Write.html
290+
/// [io_write]: ../std/io/trait.Write.html
291+
/// [enum_result]: ../std/result/enum.Result.html
292+
/// [type_result]: ../std/io/type.Result.html
268293
///
269294
/// # Examples
270295
///

0 commit comments

Comments
 (0)