Skip to content

Commit

Permalink
change
Browse files Browse the repository at this point in the history
  • Loading branch information
robertbastian committed Jun 25, 2024
1 parent 4168cf6 commit 141701d
Show file tree
Hide file tree
Showing 124 changed files with 1,613 additions and 1,518 deletions.
6 changes: 3 additions & 3 deletions components/calendar/src/week_of.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ impl WeekCalculator {
DataProvider::<WeekDataV1Marker>::load(
&provider.as_downcasting(),
DataRequest {
locale,
id: DataIdentifierBorrowed::for_locale(locale),
..Default::default()
},
)
Expand All @@ -84,7 +84,7 @@ impl WeekCalculator {
DataProvider::<WeekDataV1Marker>::load(
&provider.as_deserializing(),
DataRequest {
locale,
id: DataIdentifierBorrowed::for_locale(locale),
..Default::default()
},
)
Expand All @@ -100,7 +100,7 @@ impl WeekCalculator {
{
provider
.load(DataRequest {
locale,
id: DataIdentifierBorrowed::for_locale(locale),
..Default::default()
})
.map(|response| WeekCalculator {
Expand Down
2 changes: 1 addition & 1 deletion components/collator/src/comparison.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ impl Collator {
+ ?Sized,
{
let req = DataRequest {
locale,
id: DataIdentifierBorrowed::for_locale(locale),
..Default::default()
};

Expand Down
6 changes: 3 additions & 3 deletions components/collator/tests/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1191,7 +1191,7 @@ fn test_nb_nn_no() {
DataProvider::<CollationDataV1Marker>::load(
&icu_collator::provider::Baked,
DataRequest {
locale: &locale,
id: DataIdentifierBorrowed::for_locale(&locale),
..Default::default()
}
)
Expand All @@ -1211,7 +1211,7 @@ fn test_nb_nn_no() {
DataProvider::<CollationDataV1Marker>::load(
&icu_collator::provider::Baked,
DataRequest {
locale: &locale,
id: DataIdentifierBorrowed::for_locale(&locale),
..Default::default()
}
)
Expand All @@ -1231,7 +1231,7 @@ fn test_nb_nn_no() {
DataProvider::<CollationDataV1Marker>::load(
&icu_collator::provider::Baked,
DataRequest {
locale: &locale,
id: DataIdentifierBorrowed::for_locale(&locale),
..Default::default()
}
)
Expand Down
8 changes: 4 additions & 4 deletions components/datetime/src/calendar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ where
{
let payload = provider
.load(DataRequest {
locale,
id: DataIdentifierBorrowed::for_locale(locale),
..Default::default()
})?
.payload;
Expand All @@ -405,7 +405,7 @@ where
{
let payload = provider
.load(DataRequest {
locale,
id: DataIdentifierBorrowed::for_locale(locale),
..Default::default()
})?
.payload;
Expand Down Expand Up @@ -434,7 +434,7 @@ where
+ ?Sized,
{
let req = DataRequest {
locale,
id: DataIdentifierBorrowed::for_locale(locale),
..Default::default()
};
let payload = match kind {
Expand Down Expand Up @@ -555,7 +555,7 @@ where
+ ?Sized,
{
let req = DataRequest {
locale,
id: DataIdentifierBorrowed::for_locale(locale),
..Default::default()
};
let payload = match kind {
Expand Down
29 changes: 29 additions & 0 deletions components/datetime/src/external_loaders.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,35 @@ pub(crate) trait AnyCalendarLoader {
fn load(&self, locale: &DataLocale) -> Result<AnyCalendar, DataError>;
}

/// Helper for type resolution with optional loader arguments
pub(crate) struct PhantomLoader {
_not_constructible: core::convert::Infallible,
}

impl FixedDecimalFormatterLoader for PhantomLoader {
fn load(
&self,
_locale: &DataLocale,
_options: FixedDecimalFormatterOptions,
) -> Result<FixedDecimalFormatter, DataError> {
unreachable!() // not constructible
}
}

impl WeekCalculatorLoader for PhantomLoader {
#[inline]
fn load(&self, _locale: &DataLocale) -> Result<WeekCalculator, DataError> {
unreachable!() // not constructible
}
}

impl AnyCalendarLoader for PhantomLoader {
#[inline]
fn load(&self, _locale: &DataLocale) -> Result<AnyCalendar, DataError> {
unreachable!() // not constructible
}
}

/// Loader for types from other crates using compiled data.
#[cfg(feature = "compiled_data")]
pub(crate) struct ExternalLoaderCompiledData;
Expand Down
2 changes: 1 addition & 1 deletion components/datetime/src/format/datetime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -956,7 +956,7 @@ mod tests {

let locale = "en-u-ca-gregory".parse().unwrap();
let req = DataRequest {
locale: &locale,
id: DataIdentifierBorrowed::for_locale(&locale),
..Default::default()
};
let date_data =
Expand Down
18 changes: 9 additions & 9 deletions components/datetime/src/format/neo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1025,8 +1025,7 @@ impl<R: DateTimeNamesMarker> RawDateTimeNames<R> {
};
let payload = provider
.load_bound(DataRequest {
locale,
marker_attributes: &DataMarkerAttributes::from_tinystr(
id: DataIdentifierBorrowed::for_marker_attributes_and_locale(
marker_attrs::symbol_attr_for(
marker_attrs::Context::Format,
match field_length {
Expand All @@ -1036,6 +1035,7 @@ impl<R: DateTimeNamesMarker> RawDateTimeNames<R> {
_ => return Err(SingleLoadError::UnsupportedField(field)),
},
),
locale,
),
..Default::default()
})
Expand Down Expand Up @@ -1075,8 +1075,7 @@ impl<R: DateTimeNamesMarker> RawDateTimeNames<R> {
};
let payload = provider
.load_bound(DataRequest {
locale,
marker_attributes: &DataMarkerAttributes::from_tinystr(
id: DataIdentifierBorrowed::for_marker_attributes_and_locale(
marker_attrs::symbol_attr_for(
match field_symbol {
fields::Month::Format => marker_attrs::Context::Format,
Expand All @@ -1089,6 +1088,7 @@ impl<R: DateTimeNamesMarker> RawDateTimeNames<R> {
_ => return Err(SingleLoadError::UnsupportedField(field)),
},
),
locale,
),
..Default::default()
})
Expand Down Expand Up @@ -1127,8 +1127,7 @@ impl<R: DateTimeNamesMarker> RawDateTimeNames<R> {
let payload = R::DayPeriodNames::load_from(
provider,
DataRequest {
locale,
marker_attributes: &DataMarkerAttributes::from_tinystr(
id: DataIdentifierBorrowed::for_marker_attributes_and_locale(
marker_attrs::symbol_attr_for(
marker_attrs::Context::Format,
match field_length {
Expand All @@ -1138,6 +1137,7 @@ impl<R: DateTimeNamesMarker> RawDateTimeNames<R> {
_ => return Err(SingleLoadError::UnsupportedField(field)),
},
),
locale,
),
..Default::default()
},
Expand Down Expand Up @@ -1179,8 +1179,7 @@ impl<R: DateTimeNamesMarker> RawDateTimeNames<R> {
};
let payload = provider
.load_bound(DataRequest {
locale,
marker_attributes: &DataMarkerAttributes::from_tinystr(
id: DataIdentifierBorrowed::for_marker_attributes_and_locale(
marker_attrs::symbol_attr_for(
match field_symbol {
// UTS 35 says that "e" and "E" have the same non-numeric names
Expand All @@ -1197,6 +1196,7 @@ impl<R: DateTimeNamesMarker> RawDateTimeNames<R> {
_ => return Err(SingleLoadError::UnsupportedField(field)),
},
),
locale,
),
..Default::default()
})
Expand Down Expand Up @@ -1234,7 +1234,7 @@ impl<R: DateTimeNamesMarker> RawDateTimeNames<R> {
let payload = R::ZoneGenericShortNames::load_from(
provider,
DataRequest {
locale,
id: DataIdentifierBorrowed::for_locale(locale),
..Default::default()
},
)
Expand Down
2 changes: 1 addition & 1 deletion components/datetime/src/neo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1286,7 +1286,7 @@ impl<R: DateTimeMarkers> NeoFormatter<R> {
/// ```
pub fn convert_and_format<'a, I>(&'a self, datetime: &I) -> FormattedNeoDateTime
where
I: ConvertCalendar,
I: ?Sized + ConvertCalendar,
I::Converted<'a>: NeoGetField<<R::D as DateMarkers>::YearInput>
+ NeoGetField<<R::D as DateMarkers>::MonthInput>
+ NeoGetField<<R::D as DateMarkers>::DayOfMonthInput>
Expand Down
Loading

0 comments on commit 141701d

Please sign in to comment.