Skip to content

Documentation addition request #92276

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
alper opened this issue Dec 25, 2021 · 4 comments
Closed

Documentation addition request #92276

alper opened this issue Dec 25, 2021 · 4 comments
Labels
A-docs Area: Documentation for any part of the project, including the compiler, standard library, and tools E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. T-libs Relevant to the library team, which will review and decide on the PR/issue.

Comments

@alper
Copy link
Contributor

alper commented Dec 25, 2021

I'm trying to implement Debug occasionally, then I hit this page:
https://doc.rust-lang.org/stable/core/fmt/trait.Debug.html

The examples on that page do not contain something that uses write! so I usually google my way to the same SO answer: https://stackoverflow.com/a/22243806/102315

Could the documentation there be expanded to add this?

@sfackler
Copy link
Member

The standard way to implement debug is to use the debug builders fmt.debug_struct(..), which is documented there.

@BGR360
Copy link
Contributor

BGR360 commented Dec 26, 2021

I think this is a very reasonable ask. It doesn't make much sense to use the debug builders for very simple implementations of Debug, and for those just starting out, and the importance of using the builders for more complicated Debug impls is minimal.

@alper you'd be welcome to submit a PR with a proposed example! You just need to edit the rustdoc comment for Debug:

/// `?` formatting.

@rustbot label +T-libs A-docs +E-easy

@rustbot rustbot added A-docs Area: Documentation for any part of the project, including the compiler, standard library, and tools E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. T-docs-rs Relevant to the docs-rs subteam, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue. and removed T-docs-rs Relevant to the docs-rs subteam, which will review and decide on the PR/issue. labels Dec 26, 2021
@alper
Copy link
Contributor Author

alper commented Dec 27, 2021

Thanks, @BGR360! My PR is linked above.

matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Jan 4, 2022
…, r=dtolnay

Add another implementation example to Debug trait

As per the discussion in: rust-lang#92276
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Jan 5, 2022
…, r=dtolnay

Add another implementation example to Debug trait

As per the discussion in: rust-lang#92276
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Jan 5, 2022
…, r=dtolnay

Add another implementation example to Debug trait

As per the discussion in: rust-lang#92276
@alper
Copy link
Contributor Author

alper commented Jan 5, 2022

Thanks for the prodding. My change has now been merged. 🎉

@alper alper closed this as completed Jan 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-docs Area: Documentation for any part of the project, including the compiler, standard library, and tools E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. T-libs Relevant to the library team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

4 participants