Uh oh!
There was an error while loading. Please reload this page.
Add missing example for Display::fmt - #40299
Conversation
There was a problem hiding this comment.
This is slightly confusing because it looks like a Debug representation. How do you feel about getting rid of the Foo:: in the outputted string?
There was a problem hiding this comment.
I always add the enum's name first in case you have multiple wrappings:
enumFoo{A,}enumX{A(Foo),}enumY{A(X),}There was a problem hiding this comment.
I think you're mixing up Debug and Display. Display is for user-facing output. Users shouldn't care about enum namespacing. We don't want to encourage Rust developers to implement Display if their types aren't mean to be displayed to end-users.
How about this as the example:
structPosition{longitude:f32,latitude:f32,}impl fmt::DisplayforPosition{fnfmt(&self,f:&mut fmt::Formatter) -> fmt::Result{write!(f,"({}, {})",self.longitude,self.latitude)}}This seems a little more realistic than Foo and Bar and Stack ;)
8628d0a to
a5a3981CompareGuillaumeGomez
commented
Mar 10, 2017
Updated. |
frewsxcv
commented
Mar 11, 2017
@bors r+ rollup |
bors
commented
Mar 11, 2017
📌 Commit a5a3981 has been approved by |
… r=frewsxcv Add missing example for Display::fmt r? @frewsxcv
… r=frewsxcv Add missing example for Display::fmt r? @frewsxcv
r? @frewsxcv