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

Use is_default instead of is_empty or is_und for locale-ish types #5359

Merged
merged 4 commits into from
Aug 13, 2024

Conversation

robertbastian
Copy link
Member

Fixes #5199.

Copy link
Member Author

Choose a reason for hiding this comment

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

This wasn't discussed in the issue, but I think it's only consistent to also call it is_default instead of is_empty for Language. And because clear logically requires its result to be "empty", I removed that method (it's unused by us and trivial anyway).

Copy link
Member

Choose a reason for hiding this comment

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

Seems good

@@ -34,7 +33,7 @@ fn overview_bench(c: &mut Criterion) {
// ranging from -1e9 to 1e9.
let fdf = FixedDecimalFormatter::try_new_unstable(
&provider,
&Locale::UND.into(),
&Default::default(),
Copy link
Member

Choose a reason for hiding this comment

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

Thought, here and elsewhere: Locale::UND.into() is more clear than Default::default(); I think &Locale::default().into() would be the most clear. I also don't know whether Preferences will impl Default. @zbraniecki might have thoughts on this.

Copy link
Member

Choose a reason for hiding this comment

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

+1

Copy link
Member Author

Choose a reason for hiding this comment

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

We use Default::default() in constructors basically everywhere in tests. I don't see any value in changing a handful of invocations to Locale::default().into() now, only to change it again when we have preferences. If preferences don't implement Default, we'll have to change these call sites then anyway, so this won't be forgotten, if they do, then Default::default() is perfectly fine.

Copy link
Member

Choose a reason for hiding this comment

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

Seems good

@robertbastian robertbastian merged commit f61a5a0 into unicode-org:main Aug 13, 2024
28 checks passed
@robertbastian robertbastian deleted the und branch August 13, 2024 09:42
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.

Align Locale::is_empty, LanguageIdentifier::is_empty, and DataLocale::is_und
3 participants