Skip to content

Refactor units provider structure by renaming modules and adding new folder for units #6738

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

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions components/experimental/src/dimension/provider/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,5 @@
// (online at: https://github.com/unicode-org/icu4x/blob/main/LICENSE ).

pub mod currency;
pub mod pattern_key;
pub mod percent;
pub mod units;
pub mod units_essentials;
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ icu_provider::data_marker!(
UnitsDisplayNameV1,
UnitsDisplayName<'static>,
#[cfg(feature = "datagen")]
attributes_domain = "units"
attributes_domain = "display_names"
Copy link
Member

Choose a reason for hiding this comment

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

this is a global namespace, so just display_names is wrong

Copy link
Member Author

Choose a reason for hiding this comment

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

done

);

#[derive(Clone, PartialEq, Debug, yoke::Yokeable, zerofrom::ZeroFrom)]
Expand Down Expand Up @@ -57,11 +57,11 @@ impl<'data> UnitsDisplayName<'data> {
impl databake::Bake for UnitsDisplayName<'_> {
fn bake(&self, ctx: &databake::CrateEnv) -> databake::TokenStream {
use zerovec::ule::VarULE;
ctx.insert("icu_experimental::dimension::provider::units");
ctx.insert("icu_experimental::dimension::provider::units::display_names");
let bytes = self.patterns.elements.as_bytes().bake(ctx);
// Safety: The bytes are returned by `PluralElementsPackedULE::slice_as_bytes`.
databake::quote! { unsafe {
icu_experimental::dimension::provider::units::UnitsDisplayName::from_bytes_unchecked(#bytes)
icu_experimental::dimension::provider::units::display_names::UnitsDisplayName::from_bytes_unchecked(#bytes)
}}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ use icu_provider::prelude::*;
/// </div>
pub use crate::provider::Baked;

use super::pattern_key::PatternKey;
use super::patterns::PatternKey;

icu_provider::data_marker!(
/// `UnitsEssentialsV1`
Expand All @@ -46,7 +46,7 @@ icu_provider::data_marker!(
/// </div>
#[derive(Clone, PartialEq, Debug, yoke::Yokeable, zerofrom::ZeroFrom)]
#[cfg_attr(feature = "datagen", derive(serde::Serialize, databake::Bake))]
#[cfg_attr(feature = "datagen", databake(path = icu_experimental::dimension::provider::units_essentials))]
#[cfg_attr(feature = "datagen", databake(path = icu_experimental::dimension::provider::units::essentials))]
#[cfg_attr(feature = "serde", derive(serde::Deserialize))]
#[yoke(prove_covariance_manually)]
pub struct UnitsEssentials<'data> {
Expand All @@ -71,7 +71,7 @@ icu_provider::data_struct!(UnitsEssentials<'_>, #[cfg(feature = "datagen")]);
#[derive(Copy, Clone, PartialOrd, Ord, PartialEq, Eq, Debug)]
#[cfg_attr(feature = "serde", derive(serde::Deserialize))]
#[cfg_attr(feature = "datagen", derive(serde::Serialize, databake::Bake))]
#[cfg_attr(feature = "datagen", databake(path = icu_experimental::dimension::provider::units_essentials))]
#[cfg_attr(feature = "datagen", databake(path = icu_experimental::dimension::provider::units::essentials))]
#[repr(u8)]
pub enum CompoundCount {
/// The CLDR keyword `zero`.
Expand Down
7 changes: 7 additions & 0 deletions components/experimental/src/dimension/provider/units/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// This file is part of ICU4X. For terms of use, please see the file
// called LICENSE at the top level of the ICU4X source tree
// (online at: https://github.com/unicode-org/icu4x/blob/main/LICENSE ).

pub mod display_names;
pub mod essentials;
pub mod patterns;
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ use zerovec::{
ule::{AsULE, UleError, ULE},
};

use crate::dimension::provider::units_essentials::CompoundCount;
use crate::dimension::provider::units::essentials::CompoundCount;

#[derive(Copy, Clone, PartialOrd, Ord, PartialEq, Eq, Debug)]
#[cfg_attr(feature = "serde", derive(serde::Deserialize))]
#[cfg_attr(feature = "datagen", derive(serde::Serialize, databake::Bake))]
#[cfg_attr(feature = "datagen", databake(path = icu_experimental::dimension::provider::pattern_key))]
#[cfg_attr(feature = "datagen", databake(path = icu_experimental::dimension::provider::units::patterns))]
#[repr(u8)]
pub enum PowerValue {
Two,
Expand All @@ -25,7 +25,7 @@ pub enum PowerValue {
#[derive(Copy, Clone, PartialOrd, Ord, PartialEq, Eq, Debug)]
#[cfg_attr(feature = "serde", derive(serde::Deserialize))]
#[cfg_attr(feature = "datagen", derive(serde::Serialize, databake::Bake))]
#[cfg_attr(feature = "datagen", databake(path = icu_experimental::dimension::provider::pattern_key))]
#[cfg_attr(feature = "datagen", databake(path = icu_experimental::dimension::provider::units::patterns))]
pub enum PatternKey {
Binary(u8),
Decimal(i8),
Expand Down
2 changes: 1 addition & 1 deletion components/experimental/src/dimension/units/format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

//! Experimental.

use crate::dimension::provider::units::UnitsDisplayName;
use crate::dimension::provider::units::display_names::UnitsDisplayName;
use fixed_decimal::Decimal;
use icu_decimal::DecimalFormatter;
use icu_plurals::PluralRules;
Expand Down
4 changes: 2 additions & 2 deletions components/experimental/src/dimension/units/formatter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use icu_provider::DataPayload;

use super::format::FormattedUnit;
use super::options::{UnitsFormatterOptions, Width};
use crate::dimension::provider::units::UnitsDisplayNameV1;
use crate::dimension::provider::units::display_names::UnitsDisplayNameV1;
use icu_provider::prelude::*;
use smallvec::SmallVec;

Expand Down Expand Up @@ -133,7 +133,7 @@ impl UnitsFormatter {
) -> Result<Self, DataError>
where
D: ?Sized
+ DataProvider<super::super::provider::units::UnitsDisplayNameV1>
+ DataProvider<super::super::provider::units::display_names::UnitsDisplayNameV1>
+ DataProvider<icu_decimal::provider::DecimalSymbolsV1>
+ DataProvider<icu_decimal::provider::DecimalDigitsV1>
+ DataProvider<icu_plurals::provider::PluralsCardinalV1>,
Expand Down
2 changes: 1 addition & 1 deletion components/experimental/src/duration/formatter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// called LICENSE at the top level of the ICU4X source tree
// (online at: https://github.com/unicode-org/icu4x/blob/main/LICENSE ).

use crate::dimension::provider::units::UnitsDisplayNameV1;
use crate::dimension::provider::units::display_names::UnitsDisplayNameV1;
use crate::dimension::units::formatter::{UnitsFormatter, UnitsFormatterPreferences};
use crate::dimension::units::options::{UnitsFormatterOptions, Width};
use crate::duration::options::FieldStyle;
Expand Down
4 changes: 2 additions & 2 deletions components/experimental/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,8 @@ pub mod provider {
super::dimension::provider::currency::patterns::CurrencyPatternsDataV1::INFO,
super::dimension::provider::currency::extended::CurrencyExtendedDataV1::INFO,
super::dimension::provider::percent::PercentEssentialsV1::INFO,
super::dimension::provider::units_essentials::UnitsEssentialsV1::INFO,
super::dimension::provider::units::UnitsDisplayNameV1::INFO,
super::dimension::provider::units::essentials::UnitsEssentialsV1::INFO,
super::dimension::provider::units::display_names::UnitsDisplayNameV1::INFO,
super::displaynames::provider::LanguageDisplayNamesV1::INFO,
super::duration::provider::DigitalDurationDataV1::INFO,
super::displaynames::provider::LocaleDisplayNamesV1::INFO,
Expand Down
50,348 changes: 25,174 additions & 25,174 deletions provider/data/experimental/data/units_display_name_v1.rs.data

Large diffs are not rendered by default.

Loading
Loading