Skip to content

Commit

Permalink
Be more explicit about duck typing
Browse files Browse the repository at this point in the history
  • Loading branch information
Cengiz Can committed Aug 4, 2016
1 parent 800aa92 commit c630bea
Showing 1 changed file with 24 additions and 20 deletions.
44 changes: 24 additions & 20 deletions src/libcore/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -229,21 +229,23 @@ macro_rules! try {
})
}

/// Calls `write_fmt` function on a writer
/// Write formatted data into a buffer
///
/// This macro takes an implementor of [`std::fmt::Write`][fmt_write] or
/// [`std::io::Write`][io_write] trait, a format string, and a list of arguments.
/// This macro accepts any value with `write_fmt` method as a writer, a format string, and a list
/// of arguments to format.
///
/// Implementors of the `Write` trait are sometimes called 'writers'.
/// `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'.
///
/// These arguments will be formatted according to the specified format string and
/// the resulting string will be passed to the writer.
///
/// Return value is either [`Result`][enum_result] or [`io::Result`][type_result] depending on
/// the writer.
/// 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
/// [fmt_write]: ../std/fmt/trait.Write.html
/// [io_write]: ../std/io/trait.Write.html
Expand All @@ -267,24 +269,26 @@ macro_rules! write {
($dst:expr, $($arg:tt)*) => ($dst.write_fmt(format_args!($($arg)*)))
}

/// Calls `write_fmt` function on a writer, with appending a newline.
/// 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`).
/// On all platforms, the newline is the LINE FEED character (`\n`/`U+000A`) alone
/// (no additional CARRIAGE RETURN (`\r`/`U+000D`).
///
/// This macro takes an implementor of [`std::fmt::Write`][fmt_write] or
/// [`std::io::Write`][io_write] trait, a format string, and a list of arguments.
/// This macro accepts any value with `write_fmt` method as a writer, a format string, and a list
/// of arguments to format.
///
/// Implementors of the `Write` trait are sometimes called 'writers'.
/// `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'.
///
/// These arguments will be formatted according to the specified format string and
/// the resulting string will be passed to the writer.
///
/// Return value is either [`Result`][enum_result] or [`io::Result`][type_result] depending on
/// the writer.
/// 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
/// [fmt_write]: ../std/fmt/trait.Write.html
/// [io_write]: ../std/io/trait.Write.html
Expand Down

0 comments on commit c630bea

Please sign in to comment.