-
Notifications
You must be signed in to change notification settings - Fork 302
Closed as not planned
Labels
A-ContentThe written content on the website.The written content on the website.C-BugSomething isn't working.Something isn't working.
Description
What needs to be fixed?
format! macro documentation could be improved by changing one of the examples to be more obvious to new users.
Page(s) Affected
https://doc.rust-lang.org/std/macro.format.html
Suggested Improvement
Change example
format!("x = {}, y = {y}", 10, y = 30);
to
format!("x = {}, y = {z}", 10, z = 30);
Additionally, assert! could be used to demonstrate final string values:
let greeting = format!("hello {}", "world!");
assert!(greeting=="hello world!");
let xy = format!("x = {}, y = {z}", 10, z = 30);
assert!(xy=="x = 10, y = 30");
let (a, b) = (1, 2);
let ab = format!("{a} + {b} = 3");
assert!(ab=="1 + 2 = 3");```
Metadata
Metadata
Assignees
Labels
A-ContentThe written content on the website.The written content on the website.C-BugSomething isn't working.Something isn't working.