-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Decide on stability of Display
output for libstd/libcore/etc. types
#72676
Comments
I'm not sure what the best way to do this is. I don't think it is likely that we'll make progress without concrete questions -- certainly guaranteeing stability for a bunch of impls without going case-by-case seems like a bad idea. We've also been slowly over time changing the display output with parameters given, e.g., #72407 and similar PRs which do technically break a very strict stability guarantee interpretation. I would personally rather not explicitly guarantee anything "just because" and rather do so on a case by case basis, that is, if people ask us to. OTOH, I wouldn't expect us to change Display (or Debug, for that matter) impls with default configuration for e.g. integers at this point because that's too likely to cause breakage. But I'm not on the libs team. |
Another related issue: #72398 |
From the trait description:
This reads like it is primarily meant for human consumption. So scriptability (which I assume is the purpose of guaranteeing stability) is secondary at best. Integers are rigid enough that it shouldn't cause too much pain to guarantee specific formatting when no additional parameters are passed and even then one could envision the idea of pretty-printing very large integers to ease readability or something like that. At the extreme end there's Backtrace. In Java-land people occasionally try to match strings in backtraces and it results in very brittle behavior. Something like that shouldn't be encouraged. |
While For instance, an implementation of However, changing |
Arguably you should be using an xml-serializer and xsd schemas for that purpose instead of assembling XML by juggling strings via std formatters. E.g. JSON does not support Infinity or NaN at all, while certain XSD schemas do but only with specific capitalization which |
Even if you do use an XML serializer, using And it's not necessarily XML, it can be any human readable protocol really, maybe even an ad-hoc one. |
It probably shouldn't. But imo it's a weak argument for providing rigorous guarantees in the standard library. If you're hacking together Q&D programs then they're already expected to not be very stable / break under edge-cases. So why would it need extra guarantees? Note that even parsing an f64 with the standard library has bugs (#31407) that probably make it unsuitable for round-tripping arbitrary data. |
The Display formatting of f32 and f64 should certainly not be considered for stabilization until Rust fulfills various requirements of IEEE 754 in regards to precisely that, and I think no one should be treating it as if it is perfectly stable either. |
Per the discussion in #62794, it's not clear whether the output of
Display
impls for types in the standard library should be considered stable or unstable, and if unstable, which impls might be stable.Views expressed:
Display
impls are unstable (in this comment by @Mark-Simulacrum)Seems worth deciding on and documenting.
The text was updated successfully, but these errors were encountered: