-
Notifications
You must be signed in to change notification settings - Fork 13.1k
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
Improve the documentation of Display
and FromStr
, and their interactions
#136687
base: master
Are you sure you want to change the base?
Improve the documentation of Display
and FromStr
, and their interactions
#136687
Conversation
…actions In particular: - `Display` is not necessarily lossless - The output of `Display` might not be parseable by `FromStr`, and might not produce the same value if it is. - Calling `.parse()` on the output of `Display` is usually a mistake unless a type's documented output and input formats match. - The input formats accepted by `FromStr` depend on the type.
I think I generally agree here, but I do think making |
@BurntSushi wrote:
I'm not sure if even a description of "good practice" matches widespread community practice. "Where possible" excludes a large number of things, including things like Path/PathBuf, OsStr/OsString, BStr/BString, and many types whose In addition to that, a That said, I can attempt to tweak the language here, without making any new guarantees. |
I think there might be a misunderstanding? I'm saying that if your type provides both I agree about the delimiters and what not. But I think that's a different can of worms. :-) |
Aside: Lacking only
Personally I don't love the tight coupling between |
I added a note that "Having both |
Thanks! I'm happy with that. |
(Is that an r= or would you prefer someone else to review? :) ) |
I did a bit more of a careful review. I think the phrasing here is still a bit too pessimistic for my liking. |
5192570
to
5f82fb7
Compare
Apparently my attempt to push the change I mentioned in #136687 (comment) failed. Hopefully that helps. |
@BurntSushi I think I've addressed your concern here; please let me know if the current version doesn't address your concern. |
In particular:
Display
is not necessarily losslessDisplay
might not be parseable byFromStr
, and mightnot produce the same value if it is.
.parse()
on the output ofDisplay
is usually a mistakeunless a type's documented output and input formats match.
FromStr
depend on the type.This documentation adds no API surface area and makes no guarantees about stability. To the best of my knowledge, everything it says is already established to be true. As such, I don't think it needs an FCP.