Skip to content

Format Macro Named Argument Example is Confusing #1862

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
thisisscotts opened this issue Sep 5, 2023 · 4 comments
Closed

Format Macro Named Argument Example is Confusing #1862

thisisscotts opened this issue Sep 5, 2023 · 4 comments
Labels
A-Content The written content on the website. C-Bug Something isn't working.

Comments

@thisisscotts
Copy link

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");```
@thisisscotts thisisscotts added A-Content The written content on the website. C-Bug Something isn't working. labels Sep 5, 2023
@Manishearth
Copy link
Member

This is the tracker for the website, please post on rust-lang/rust for the stdlib and its docs.

@thisisscotts
Copy link
Author

@Manishearth Sorry, this is my first contribution on github ever. Have I missed something?

My intention was to have the documentation updated to help new users (like me).

@Manishearth Manishearth closed this as not planned Won't fix, can't repro, duplicate, stale Sep 5, 2023
@Manishearth
Copy link
Member

Yes, this is the wrong repository for documentation fixes, this repository is for www.rust-lang.org only. Check out https://github.com/rust-lang/rust instead

@thisisscotts
Copy link
Author

Will do, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Content The written content on the website. C-Bug Something isn't working.
Projects
None yet
Development

No branches or pull requests

2 participants