-
Notifications
You must be signed in to change notification settings - Fork 183
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
Add missing keys to CollatorPreferences
#5950
base: main
Are you sure you want to change the base?
Conversation
ffa47b4
to
2849caa
Compare
Looks OK to me, but I let @zbraniecki review the macro usage. |
Thank you for the PR! The only thing I'd like to ponder over is that you're introducing an example where our sepration of Preferences and Options gets blurry - the developer sets an option, and user may set another. We have to decide who takes precedence. |
@zbraniecki FWIW, on ECMA402 explicit configs take priority over unicode keys, so I expressed that here. If we want to add more flexibility for it, I think we can add an option to explicitly prioritise either one of them. |
components/collator/src/options.rs
Outdated
CollationCaseFirst::Upper => CaseFirst::UpperFirst, | ||
CollationCaseFirst::Lower => CaseFirst::LowerFirst, | ||
CollationCaseFirst::False => CaseFirst::Off, | ||
_ => unreachable!("`CaseFirst` and `CollationCaseFirst` must always be in sync."), |
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.
q
: Should we panic here or debug_assert and in release select [default]
?
components/collator/src/options.rs
Outdated
CaseFirst::Off => CollationCaseFirst::False, | ||
CaseFirst::LowerFirst => CollationCaseFirst::Lower, | ||
CaseFirst::UpperFirst => CollationCaseFirst::Upper, | ||
} |
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.
Why you don't need a catch case despite CaseFirst being non-exhaustive?
Should we switch Options to use CollactionCaseFirst from Preferences then?
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.
#[non_exhaustive]
only applies for external crates that use the enum.
I preserved the old enum because I wanted to avoid unnecessary breaking changes, but we can switch to that if preferred.
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.
We have a shot at doing it in 2.0, I think i'd prefer that. @sffc @Manishearth @robertbastian - you ok with that?
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.
I have a slight preference for removing the settings from options
and moving them to preferences
in 2.0
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.
Same.
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.
Just to be clear – we would move the relevant options to CollatorPreferences
, using the structs on icu_locale_core
, and the rest of the options would still be in CollatorOptions
, is that right?
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.
correct!
Ok, switched it to use preference keyword structs and removed the old config structs. Had to slightly adjust the documentation to mention |
Oh, interesting. Am I correct to read your PR as - you removed the two preferences from Options, and allow for setting it by the developer by overriding Preferences? In other words if the developer wants to set one of those two, they interact with Preferences bag, not Options bag anymore? |
@zbraniecki Yes. That way, the problem we had about priority is solved in an arguably cleaner way, since users can either |
Ok, so you think this is even a cleaner approach! I value your perspective as an implementer. I think I have a hard time deciding on the tradeoffs around it. With your change we're telling developers to touch Preferences manually. The value of it is that, as you rightly pointed out, it is clean and allows developers to control which direction they want to merge - options->prefs, or prefs->options. ECMA-402 specifies one, but that doesn't mean everyone has to repeat it. The downsides are:
I think I'm fine with that as the benefit outweights the cost for me but wanted to have this explicit paper trail of this decision to revisit in the future. |
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.
lgtm! thank you!
Adds support for
kn
andkf
onCollatorPreferences
.