Skip to content

Commit

Permalink
Rollup merge of #49619 - durka:patch-46, r=steveklabnik
Browse files Browse the repository at this point in the history
tweak core::fmt docs

Remove an outdated (pre-1.0!) claim about passing something or other to a function. Also swap the variable names in the example.
  • Loading branch information
kennytm committed Apr 3, 2018
2 parents 572fabd + 333b0a0 commit feb7e4a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
11 changes: 5 additions & 6 deletions src/libcore/fmt/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -401,19 +401,18 @@ impl<'a> Arguments<'a> {
/// safely be done, so no constructors are given and the fields are private
/// to prevent modification.
///
/// The [`format_args!`] macro will safely create an instance of this structure
/// and pass it to a function or closure, passed as the first argument. The
/// macro validates the format string at compile-time so usage of the [`write`]
/// and [`format`] functions can be safely performed.
/// The [`format_args!`] macro will safely create an instance of this structure.
/// The macro validates the format string at compile-time so usage of the
/// [`write`] and [`format`] functions can be safely performed.
///
/// You can use the `Arguments<'a>` that [`format_args!`] returns in `Debug`
/// and `Display` contexts as seen below. The example also shows that `Debug`
/// and `Display` format to the same thing: the interpolated format string
/// in `format_args!`.
///
/// ```rust
/// let display = format!("{:?}", format_args!("{} foo {:?}", 1, 2));
/// let debug = format!("{}", format_args!("{} foo {:?}", 1, 2));
/// let debug = format!("{:?}", format_args!("{} foo {:?}", 1, 2));
/// let display = format!("{}", format_args!("{} foo {:?}", 1, 2));
/// assert_eq!("1 foo 2", display);
/// assert_eq!(display, debug);
/// ```
Expand Down
4 changes: 2 additions & 2 deletions src/libstd/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -341,8 +341,8 @@ pub mod builtin {
/// format string in `format_args!`.
///
/// ```rust
/// let display = format!("{:?}", format_args!("{} foo {:?}", 1, 2));
/// let debug = format!("{}", format_args!("{} foo {:?}", 1, 2));
/// let debug = format!("{:?}", format_args!("{} foo {:?}", 1, 2));
/// let display = format!("{}", format_args!("{} foo {:?}", 1, 2));
/// assert_eq!("1 foo 2", display);
/// assert_eq!(display, debug);
/// ```
Expand Down

0 comments on commit feb7e4a

Please sign in to comment.