Skip to content
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

WIP preferences #5573

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft

Conversation

robertbastian
Copy link
Member

@robertbastian robertbastian commented Sep 23, 2024

Copy link
Member

@sffc sffc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good initial pass; the style is different between icu_collator and icu_decimal

Comment on lines 191 to 198
impl ResolvedFixedDecimalFormatterPreferences {
fn as_data_id(&self) -> DataIdentifierBorrowed {
DataIdentifierBorrowed::for_marker_attributes_and_locale(
DataMarkerAttributes::from_str_or_panic(
self.numbering_system.0.as_str()
),
&self.data_locale,
)
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Praise: I like the pattern of pre-computing the DataLocale and putting this code into an associated function.

#[allow(clippy::unwrap_used)] // temporary
ResolvedFixedDecimalFormatterPreferences {
data_locale: DataLocale::from(self.lid),
numbering_system: self.numbering_system.unwrap(),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Issue: it should just be stored as an Option, I think? We don't actually have a way to retrieve the resolved numbering system from data because that wasn't a design constraint until now. Maybe we should add it to DecimalSymbolsV2, #4437

fn from(loc: icu_locale_core::Locale) -> Self {

let lid = Some(loc.id);
impl<'a> From<&'a $crate::preferences::icu_locale_core::Locale> for $name<'a> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Discussion: Do we want an impl from both Locale and &Locale?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please post discussions in the issue

impl<'a> From<&'a ResolvedCollatorPreferences> for DataIdentifierCow<'a> {
fn from(value: &'a ResolvedCollatorPreferences) -> Self {
Self::from_borrowed_and_owned(
match value.collation_type {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Question: should this match live here or in icu_preferences code?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants