Skip to content
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

Add another implementation example to Debug trait #92322

Merged
merged 2 commits into from
Jan 5, 2022

Conversation

alper
Copy link
Contributor

@alper alper commented Dec 27, 2021

As per the discussion in: #92276

@rust-highfive
Copy link
Collaborator

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @dtolnay (or someone else) soon.

Please see the contribution instructions for more information.

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Dec 27, 2021
@rust-log-analyzer

This comment has been minimized.

@@ -570,8 +570,23 @@ impl Display for Arguments<'_> {
/// There are a number of helper methods on the [`Formatter`] struct to help you with manual
/// implementations, such as [`debug_struct`].
///
/// `Debug` implementations using either `derive` or the debug builder API
/// on [`Formatter`] support pretty-printing using the alternate flag: `{:#?}`.
/// For simple cases, it's also possible to implement `Debug` using the [`write!`] macro:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Simple vs non-simple isn't necessarily the right distinction to draw here. Standard vs non-standard is probably more like it. In other words types that do not wish to use the standard suite of debug representations provided by the Formatter trait (debug_struct, debug_tuple, debut_list, debug_set, debug_map) can do something totally custom by manually writing an arbitrary representation to the Formatter.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Made this change.

Comment on lines 588 to 589
/// `Debug` implementations that have been created automatically by `derive` or implemented
/// manually using a [`Formatter`] can be used by pretty-printing with the alternate flag: `{:#?}`.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel like this sentence was more meaningful the way it was prior to the PR. All Debug implementations use a Formatter because that's dictated by the trait signature, and generally speaking all Debug implementations are either derived1 or manually implemented. So it's no longer clear what set of implementations is not covered by the description "created automatically by derive or implemented manually using a Formatter".

Footnotes

  1. macro-generated

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reverted this.

@dtolnay dtolnay added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Dec 29, 2021
@dtolnay dtolnay force-pushed the add_debug_trait_documentation branch from 703f97f to 1773e83 Compare January 4, 2022 22:31
/// # }
///
/// impl fmt::Debug for Point {
/// fn fmt(&self, f: &mut fmt::Formatter <'_>) -> fmt::Result {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// fn fmt(&self, f: &mut fmt::Formatter <'_>) -> fmt::Result {
/// fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {

Copy link
Member

@dtolnay dtolnay left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@dtolnay
Copy link
Member

dtolnay commented Jan 4, 2022

@bors r+ rollup

@bors
Copy link
Contributor

bors commented Jan 4, 2022

📌 Commit 4df1a55 has been approved by dtolnay

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jan 4, 2022
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request 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 pull request Jan 5, 2022
…, r=dtolnay

Add another implementation example to Debug trait

As per the discussion in: rust-lang#92276
bors added a commit to rust-lang-ci/rust that referenced this pull request Jan 5, 2022
…askrgr

Rollup of 7 pull requests

Successful merges:

 - rust-lang#92182 (Label more build steps)
 - rust-lang#92188 (rustdoc: Clean up NestedAttributesExt trait/implementation)
 - rust-lang#92322 (Add another implementation example to Debug trait)
 - rust-lang#92448 (Set font size proportional to user's font size)
 - rust-lang#92517 (Explicitly pass `PATH` to the Windows exe resolver)
 - rust-lang#92545 (Extract init_env_logger to crate)
 - rust-lang#92579 (update Miri)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit a0262fd into rust-lang:master Jan 5, 2022
@rustbot rustbot added this to the 1.59.0 milestone Jan 5, 2022
@alper alper deleted the add_debug_trait_documentation branch January 5, 2022 18:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants