Skip to content

Commit 42d58ae

Browse files
authored
Rollup merge of rust-lang#100855 - IsaacCloos:master, r=joshtriplett
Extra documentation for new formatting feature Documentation of this feature was added in rust-lang#90473 and released in Rust 1.58. However, high traffic macros did not receive new examples. Namely `println!()` and `format!()`. The doc comments included in Rust are super important to the community- especially newcomers. I have met several other newbies like myself who are unaware of this recent (well about 7 months old now) update to the language allowing for convenient intra-string identifiers. Bringing small examples of this feature to the doc comments of `println!()` and `format!()` would be helpful to everyone learning the language. [Blog Post Announcing Feature](https://blog.rust-lang.org/2022/01/13/Rust-1.58.0.html) [Feature PR](rust-lang#90473) - includes several instances of documentation of the feature- minus the macros in question for this PR *This is my first time contributing to a project this large. Feedback would mean the world to me 😄* --- *Recreated; I violated the [No-Merge Policy](https://rustc-dev-guide.rust-lang.org/git.html#no-merge-policy)*
2 parents 0d5223d + acca4b8 commit 42d58ae

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

library/alloc/src/macros.rs

+2
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,8 @@ macro_rules! vec {
107107
/// format!("test");
108108
/// format!("hello {}", "world!");
109109
/// format!("x = {}, y = {y}", 10, y = 30);
110+
/// let (x, y) = (1, 2);
111+
/// format!("{x} + {y} = 3");
110112
/// ```
111113
#[macro_export]
112114
#[stable(feature = "rust1", since = "1.0.0")]

library/std/src/macros.rs

+2
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,8 @@ macro_rules! print {
9393
/// println!(); // prints just a newline
9494
/// println!("hello there!");
9595
/// println!("format {} arguments", "some");
96+
/// let local_variable = "some";
97+
/// println!("format {local_variable} arguments");
9698
/// ```
9799
#[macro_export]
98100
#[stable(feature = "rust1", since = "1.0.0")]

0 commit comments

Comments
 (0)