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

Unifying DataLocale construction #4912

Merged
merged 2 commits into from
May 21, 2024
Merged

Conversation

robertbastian
Copy link
Member

In preparation for #3632

There are two cases:

  • DataLocales that are passed into ICU4X constructors:
    • These are constructed with locale!("foo").into(), or "foo".parse()
    • When changing a constructor to preferences, the code doesn't need to be changed if we add a From<Locale> impl for the preferences
  • DataLocales that are put into the DataRequest::locale field.
    • These are constructed with langid!("foo").into(), or "foo".parse()
    • When changing the field to &LanguageIdentifier, these can be clippy-cleaned-up, as the .into() will become redundant.

I've taken care to avoid having intermediate Locale or LanguageIdentifier variables, everything that is macro-constructed is immediately into()ed. This will simplify find-and-replace later.

@@ -832,8 +831,8 @@ mod tests {
use icu_calendar::japanese::JapaneseExtended;
use icu_calendar::Date;

let locale: Locale = "en-u-ca-japanese".parse().unwrap();
let dtf = NeoDateFormatter::try_new_with_length(&locale.into(), length::Date::Medium)
let locale = "en-u-ca-japanese".parse().unwrap();
Copy link
Member

Choose a reason for hiding this comment

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

Thought: This one involves impl FromStr for DateTimePreferences

///
/// let zdtf = ZonedDateTimeFormatter::try_new(
/// &locale.into(),
/// &locale,
Copy link
Member

@sffc sffc May 21, 2024

Choose a reason for hiding this comment

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

Thought: All of these examples assume that Preferences will be borrowed. Have we had that discussion? Because it could also be a Copy type that borrows the LanguageIdentifier.

@robertbastian robertbastian merged commit 0776faf into unicode-org:main May 21, 2024
30 checks passed
@robertbastian robertbastian deleted the dl branch May 28, 2024 19:56
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