Skip to content

Commit 94e651b

Browse files
committed
Update doc for alloc::format! and core::concat!
1 parent c1d80ba commit 94e651b

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

library/alloc/src/macros.rs

+9-5
Original file line numberDiff line numberDiff line change
@@ -88,15 +88,19 @@ macro_rules! vec {
8888
///
8989
/// A common use for `format!` is concatenation and interpolation of strings.
9090
/// The same convention is used with [`print!`] and [`write!`] macros,
91-
/// depending on the intended destination of the string.
91+
/// depending on the intended destination of the string; all these macros internally use [`format_args!`].
9292
///
9393
/// To convert a single value to a string, use the [`to_string`] method. This
9494
/// will use the [`Display`] formatting trait.
9595
///
96+
/// To concatenate literals into a `&'static str`, use the [`concat!`] macro.
97+
///
9698
/// [`print!`]: ../std/macro.print.html
9799
/// [`write!`]: core::write
100+
/// [`format_args!`]: core::format_args
98101
/// [`to_string`]: crate::string::ToString
99102
/// [`Display`]: core::fmt::Display
103+
/// [`concat!`]: core::concat
100104
///
101105
/// # Panics
102106
///
@@ -107,11 +111,11 @@ macro_rules! vec {
107111
/// # Examples
108112
///
109113
/// ```
110-
/// format!("test");
111-
/// format!("hello {}", "world!");
112-
/// format!("x = {}, y = {y}", 10, y = 30);
114+
/// format!("test"); // => "test"
115+
/// format!("hello {}", "world!"); // => "hello world!"
116+
/// format!("x = {}, y = {val}", 10, val = 30); // => "x = 10, y = 30"
113117
/// let (x, y) = (1, 2);
114-
/// format!("{x} + {y} = 3");
118+
/// format!("{x} + {y} = 3"); // => "1 + 2 = 3"
115119
/// ```
116120
#[macro_export]
117121
#[stable(feature = "rust1", since = "1.0.0")]

library/core/src/macros/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1044,7 +1044,7 @@ pub(crate) mod builtin {
10441044
/// expression of type `&'static str` which represents all of the literals
10451045
/// concatenated left-to-right.
10461046
///
1047-
/// Integer and floating point literals are stringified in order to be
1047+
/// Integer and floating point literals are [stringified](core::stringify) in order to be
10481048
/// concatenated.
10491049
///
10501050
/// # Examples

0 commit comments

Comments
 (0)