summaryrefslogtreecommitdiffstats
path: root/library/alloc/src/macros.rs
diff options
context:
space:
mode:
Diffstat (limited to 'library/alloc/src/macros.rs')
-rw-r--r--library/alloc/src/macros.rs21
1 files changed, 13 insertions, 8 deletions
diff --git a/library/alloc/src/macros.rs b/library/alloc/src/macros.rs
index 4c6ae8f25..0f767df60 100644
--- a/library/alloc/src/macros.rs
+++ b/library/alloc/src/macros.rs
@@ -79,23 +79,28 @@ macro_rules! vec {
///
/// The first argument `format!` receives is a format string. This must be a string
/// literal. The power of the formatting string is in the `{}`s contained.
-///
/// Additional parameters passed to `format!` replace the `{}`s within the
/// formatting string in the order given unless named or positional parameters
-/// are used; see [`std::fmt`] for more information.
+/// are used.
+///
+/// See [the formatting syntax documentation in `std::fmt`](../std/fmt/index.html)
+/// for details.
///
/// A common use for `format!` is concatenation and interpolation of strings.
/// The same convention is used with [`print!`] and [`write!`] macros,
-/// depending on the intended destination of the string.
+/// depending on the intended destination of the string; all these macros internally use [`format_args!`].
///
/// To convert a single value to a string, use the [`to_string`] method. This
/// will use the [`Display`] formatting trait.
///
-/// [`std::fmt`]: ../std/fmt/index.html
+/// To concatenate literals into a `&'static str`, use the [`concat!`] macro.
+///
/// [`print!`]: ../std/macro.print.html
/// [`write!`]: core::write
+/// [`format_args!`]: core::format_args
/// [`to_string`]: crate::string::ToString
/// [`Display`]: core::fmt::Display
+/// [`concat!`]: core::concat
///
/// # Panics
///
@@ -106,11 +111,11 @@ macro_rules! vec {
/// # Examples
///
/// ```
-/// format!("test");
-/// format!("hello {}", "world!");
-/// format!("x = {}, y = {y}", 10, y = 30);
+/// format!("test"); // => "test"
+/// format!("hello {}", "world!"); // => "hello world!"
+/// format!("x = {}, y = {val}", 10, val = 30); // => "x = 10, y = 30"
/// let (x, y) = (1, 2);
-/// format!("{x} + {y} = 3");
+/// format!("{x} + {y} = 3"); // => "1 + 2 = 3"
/// ```
#[macro_export]
#[stable(feature = "rust1", since = "1.0.0")]