Skip to content

Commit c630bea

Browse files
author
Cengiz Can
committed
Be more explicit about duck typing
1 parent 800aa92 commit c630bea

File tree

1 file changed

+24
-20
lines changed

1 file changed

+24
-20
lines changed

src/libcore/macros.rs

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -229,21 +229,23 @@ macro_rules! try {
229229
})
230230
}
231231

232-
/// Calls `write_fmt` function on a writer
232+
/// Write formatted data into a buffer
233233
///
234-
/// This macro takes an implementor of [`std::fmt::Write`][fmt_write] or
235-
/// [`std::io::Write`][io_write] trait, a format string, and a list of arguments.
234+
/// This macro accepts any value with `write_fmt` method as a writer, a format string, and a list
235+
/// of arguments to format.
236236
///
237-
/// Implementors of the `Write` trait are sometimes called 'writers'.
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'.
238239
///
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.
240+
/// Passed arguments will be formatted according to the specified format string and the resulting
241+
/// string will be passed to the writer.
244242
///
245243
/// See [`std::fmt`][fmt] for more information on format syntax.
246244
///
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+
///
247249
/// [fmt]: ../std/fmt/index.html
248250
/// [fmt_write]: ../std/fmt/trait.Write.html
249251
/// [io_write]: ../std/io/trait.Write.html
@@ -267,24 +269,26 @@ macro_rules! write {
267269
($dst:expr, $($arg:tt)*) => ($dst.write_fmt(format_args!($($arg)*)))
268270
}
269271

270-
/// Calls `write_fmt` function on a writer, with appending a newline.
272+
/// Write formatted data into a buffer, with appending a newline.
271273
///
272-
/// On all platforms, the newline is the LINE FEED character (`\n`/`U+000A`)
273-
/// alone (no additional CARRIAGE RETURN (`\r`/`U+000D`).
274+
/// On all platforms, the newline is the LINE FEED character (`\n`/`U+000A`) alone
275+
/// (no additional CARRIAGE RETURN (`\r`/`U+000D`).
274276
///
275-
/// This macro takes an implementor of [`std::fmt::Write`][fmt_write] or
276-
/// [`std::io::Write`][io_write] trait, a format string, and a list of arguments.
277+
/// This macro accepts any value with `write_fmt` method as a writer, a format string, and a list
278+
/// of arguments to format.
277279
///
278-
/// Implementors of the `Write` trait are sometimes called 'writers'.
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'.
279282
///
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.
283+
/// Passed arguments will be formatted according to the specified format string and the resulting
284+
/// string will be passed to the writer.
285285
///
286286
/// See [`std::fmt`][fmt] for more information on format syntax.
287287
///
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+
///
288292
/// [fmt]: ../std/fmt/index.html
289293
/// [fmt_write]: ../std/fmt/trait.Write.html
290294
/// [io_write]: ../std/io/trait.Write.html

0 commit comments

Comments
 (0)