diff options
| author | bors <bors@rust-lang.org> | 2018-12-30 07:12:13 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2018-12-30 07:12:13 +0000 |
| commit | 0e6f8987aac22bfeef36d708aa60ed7be6ff89b7 (patch) | |
| tree | 876e04cb72bf4c89bfe231e0cf2dc537ff0d665d /src/liballoc/macros.rs | |
| parent | 171c1fc25ed22e34fa4f666a15909b762ac1307b (diff) | |
| parent | 56d6ff0634e61bcf0a1e26c27cf346f5d170eb59 (diff) | |
Auto merge of #57195 - czipperz:mention_ToString_in_std_fmt_docs, r=SimonSapin
Mention ToString in std::fmt docs
I believe this should be added because `x.to_string()` is preferred over `format!("{}", x)` as the recommended way to convert a value to a string. `std::fmt` and the `format` macro is where people look for documentation about this, and thus we should include references to this preferred functions there.
Resolves #55065
Diffstat (limited to 'src/liballoc/macros.rs')
| -rw-r--r-- | src/liballoc/macros.rs | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/src/liballoc/macros.rs b/src/liballoc/macros.rs index 1978efda097..db91b07fa71 100644 --- a/src/liballoc/macros.rs +++ b/src/liballoc/macros.rs @@ -73,9 +73,14 @@ macro_rules! vec { /// The same convention is used with [`print!`] and [`write!`] macros, /// depending on the intended destination of the string. /// +/// To convert a single value to a string, use the [`to_string`] method. This +/// will use the [`Display`] formatting trait. +/// /// [fmt]: ../std/fmt/index.html /// [`print!`]: ../std/macro.print.html /// [`write!`]: ../std/macro.write.html +/// [`to_string`]: ../std/string/trait.ToString.html +/// [`Display`]: ../std/fmt/trait.Display.html /// /// # Panics /// |
