-
Notifications
You must be signed in to change notification settings - Fork 175
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
Reaffirm TryWriteable design #5494
Comments
Note: if we implement Display, then we should also plan to implement a concrete to_string. |
Doubly nested Results are required in case the |
A lossy Display seems nice to have. I think the original design of having these be mutually exclusive is fine. |
I'm not sure I agree. If I have a type that is fallible, and I want to display it in |
That's not what I'm trying to get at. If |
Ah, I see! Thanks for explaining that to me. I haven't consider Infallible. I'm convinced. |
What did people think about implementing |
Not much, errors should be handled or explicitly ignored. |
To continue this conversation: FormattedNeoDateTime implements TryWriteable. TryWriteable, as noted above, has a funny API signature, and developers are presented with decisions about error handling that they are not in the best position to reason about. In "normal" call sites, the TryWriteable won't fail. I have an example in the docs where it is possible to make it fail via manual data loading in the lower-level power user types DateTimeNames and DateTimePattern. Getting it to fail is even harder if you come in via the high-level icu::datetime::Formatter APIs; it is possible, but you would need a custom data provider and/or a custom input type. (The custom input type failure case might go away depending on the resolution to #5269) Experience has sometimes shown that using the lossy behavior is superior to throwing an error. Citation: there was a Google app that had a panic when a unit formatting call failed due to missing data, and it just basically showed up in logs and it took engineers months to get around to investigating it, but meanwhile users in the affected languages were unable to use the app. When the engineers finally tried to reproduce the error, it was unclear what the impact was, because they were unable to see which string in the UI was at fault. If the error had been lossy instead, the bug would have been in the form of screenshots that didn't look right, and users would have still been able to use the app. I know we usually say "loud errors are better", but i18n is all about best-effort. For the reasons above, I would like to see us move forward with a "lossy" Display impl on TryWriteable types. This also means a concrete I'd also be happy with a narrower proposal to impl Display specifically on FormattedNeoDateTime but not in general on TryWriteables. |
If our recommendation is for |
Proposal:
LGTM: @sffc @robertbastian @Manishearth @hsivonen @nekevss (@echeran) |
From #5493
We previously made two design decisions about TryWriteable that might be worth revisiting before 2.0:
My initial position is that I stand by both of these choices, though I could be convinced that we should implement a lossy Display on TryWriteable types.
Anyone want to weigh in?
@zbraniecki @robertbastian @Manishearth
The text was updated successfully, but these errors were encountered: