-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Significantly improve formatter trait docs #26828
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
Conversation
(rust_highfive has picked a reviewer for you, use r? to override) |
/// | ||
/// // convert val to base 8 here in a real implementation | ||
/// | ||
/// write!(f, "{}", val) |
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.
Can you use {:o}
to format val
here? Same with the binary case, you'd just reuse {:b}
on the inner value. Maybe it's a bit confusing but that's what a real world impl would do I think.
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.
Yeah, so originally, I started out with a type that was just a unit struct, but then in an effort to make it more real, switched to Length
.
Thanks @bluss, even better now :) |
/// impl fmt::UpperExp for Length { | ||
/// fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { | ||
/// let val = self.0; | ||
/// write!(f, "{}.0E-11", val) |
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.
sorry to ask again, but is this intended to be accurate? Then it should be {}.0E0
.
r=me with the scientific notation confirmed and tidy errors fixed! Nice new avatar! |
Each formatting trait now has an example of implementation, as well as a fuller description of what it's supposed to output. It also contains a link to the module-level documentation which Fixes rust-lang#25765
@bors: r=bluss rollup |
📌 Commit 3a6cd64 has been approved by |
Thanks :) been using it on Twitter for a while, realized I forgot to update it here... |
Each formatting trait now has an example of implementation, as well as a fuller description of what it's supposed to output. It also contains a link to the module-level documentation which Fixes rust-lang#25765
Each formatting trait now has an example of implementation, as well as a fuller description of what it's supposed to output. It also contains a link to the module-level documentation which Fixes rust-lang#25765
Each formatting trait now has an example of implementation, as well as a fuller description of what it's supposed to output. It also contains a link to the module-level documentation which Fixes rust-lang#25765
Each formatting trait now has an example of implementation, as well as a
fuller description of what it's supposed to output.
It also contains a link to the module-level documentation which
Fixes #25765