-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Document that Display entails ToString and should be lossless and infallible #94488
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -703,11 +703,21 @@ pub use macros::Debug; | |||||
|
||||||
/// Format trait for an empty format, `{}`. | ||||||
/// | ||||||
/// `Display` is similar to [`Debug`], but `Display` is for user-facing | ||||||
/// output, and so cannot be derived. | ||||||
/// `Display` is similar to [`Debug`], but `Display` is for user-facing output, | ||||||
/// and so cannot be derived. When `Display` is implemented, the [`ToString`] | ||||||
/// trait is implemented automatically, adding the `to_string` method to all | ||||||
/// `Display` types. | ||||||
/// | ||||||
/// A `Display` implementation should be lossless and infallible, otherwise it | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How do you define lossless here? Any definition I can think of feels way too strict.. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. "doesn't lose information from its internal data" and then we can use |
||||||
/// does not fit the API. For example, converting a path to a [`String`] is | ||||||
/// potentially lossy or fallible, so [`Path`] doesn’t implement `Display` | ||||||
/// directly (but offers a .display() method). | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
/// | ||||||
/// For more information on formatters, see [the module-level documentation][module]. | ||||||
/// | ||||||
/// [`Path`]: ../../std/path/struct.Path.html | ||||||
/// [`ToString`]: ../../std/string/trait.ToString.html | ||||||
/// [`String`]: ../../std/string/struct.String.html | ||||||
/// [module]: ../../std/fmt/index.html | ||||||
/// | ||||||
/// # Examples | ||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As long as we're fixing this documentation: this conclusion doesn't actually automatically follow, and might not always be true.