diff --git a/components/datetime/src/error.rs b/components/datetime/src/error.rs index ee84dd5f1a8..407201dd3c0 100644 --- a/components/datetime/src/error.rs +++ b/components/datetime/src/error.rs @@ -11,7 +11,7 @@ use icu_calendar::{ use icu_provider::DataError; #[cfg(doc)] -use crate::pattern::TypedDateTimeNames; +use crate::pattern::FixedCalendarDateTimeNames; #[cfg(doc)] use icu_calendar::types::YearInfo; #[cfg(doc)] @@ -90,7 +90,7 @@ pub enum DateTimeWriteError { /// The [`DecimalFormatter`] has not been loaded. /// /// This *only* happens if the formatter has been created using - /// [`TypedDateTimeNames::with_pattern_unchecked`], the pattern requires decimal + /// [`FixedCalendarDateTimeNames::with_pattern_unchecked`], the pattern requires decimal /// formatting, and the decimal formatter was not loaded. /// /// The output will contain fallback values using Latin numerals. @@ -99,7 +99,7 @@ pub enum DateTimeWriteError { /// The localized names for a field have not been loaded. /// /// This *only* happens if the formatter has been created using - /// [`TypedDateTimeNames::with_pattern_unchecked`], and the pattern requires names + /// [`FixedCalendarDateTimeNames::with_pattern_unchecked`], and the pattern requires names /// that were not loaded. /// /// The output will contain fallback values using field identifiers (such as `tue` for `IsoWeekday::Tuesday`, @@ -109,7 +109,7 @@ pub enum DateTimeWriteError { /// An input field (such as "hour" or "month") is missing. /// /// This *only* happens if the formatter has been created using - /// [`TypedDateTimeNames::with_pattern_unchecked`], and the pattern requires fields + /// [`FixedCalendarDateTimeNames::with_pattern_unchecked`], and the pattern requires fields /// that are not returned by the input type. /// /// The output will contain the string `{X}` instead, where `X` is the symbol for which the input is missing. @@ -118,7 +118,7 @@ pub enum DateTimeWriteError { /// The pattern contains a field that has a valid symbol but invalid length. /// /// This *only* happens if the formatter has been created using - /// [`TypedDateTimeNames::with_pattern_unchecked`], and the pattern contains + /// [`FixedCalendarDateTimeNames::with_pattern_unchecked`], and the pattern contains /// a field with a length not supported in formatting. /// /// The output will contain fallback values similar to [`DateTimeWriteError::NamesNotLoaded`]. @@ -127,7 +127,7 @@ pub enum DateTimeWriteError { /// Unsupported field /// /// This *only* happens if the formatter has been created using - /// [`TypedDateTimeNames::with_pattern_unchecked`], and the pattern contains unsupported fields. + /// [`FixedCalendarDateTimeNames::with_pattern_unchecked`], and the pattern contains unsupported fields. /// /// The output will contain the string `{unsupported:X}`, where `X` is the symbol of the unsupported field. #[displaydoc("Unsupported field {0:?}")] diff --git a/components/datetime/src/neo.rs b/components/datetime/src/neo.rs index 76191cb2589..7915055ac09 100644 --- a/components/datetime/src/neo.rs +++ b/components/datetime/src/neo.rs @@ -764,7 +764,7 @@ impl FixedCalendarDateTimeFormatter(); + /// let general_formatter = specific_formatter.cast_into_fset::(); /// /// // Test that it still works: /// assert_writeable_eq!( @@ -772,12 +772,12 @@ impl FixedCalendarDateTimeFormatter>( + pub fn cast_into_fset>( self, ) -> FixedCalendarDateTimeFormatter { FixedCalendarDateTimeFormatter { selection: self.selection, - names: self.names.with_fset(), + names: self.names.cast_into_fset(), _calendar: PhantomData, } } @@ -880,7 +880,7 @@ impl DateTimeFormatter { /// ); /// /// // Make a more general formatter: - /// let general_formatter = specific_formatter.with_fset::(); + /// let general_formatter = specific_formatter.cast_into_fset::(); /// /// // Test that it still works: /// assert_writeable_eq!( @@ -888,10 +888,10 @@ impl DateTimeFormatter { /// "20 déc. 2024" /// ); /// ``` - pub fn with_fset>(self) -> DateTimeFormatter { + pub fn cast_into_fset>(self) -> DateTimeFormatter { DateTimeFormatter { selection: self.selection, - names: self.names.with_fset(), + names: self.names.cast_into_fset(), calendar: self.calendar, } } diff --git a/components/datetime/src/pattern/formatter.rs b/components/datetime/src/pattern/formatter.rs index 55f8dcd4e5d..235f8fae945 100644 --- a/components/datetime/src/pattern/formatter.rs +++ b/components/datetime/src/pattern/formatter.rs @@ -22,10 +22,10 @@ use writeable::TryWriteable; /// It assumes that the pattern is already localized for the customer's locale. Most clients /// should use [`DateTimeFormatter`] instead of directly formatting with patterns. /// -/// Create one of these via factory methods on [`TypedDateTimeNames`]. +/// Create one of these via factory methods on [`FixedCalendarDateTimeNames`]. /// /// [`DateTimePattern`]: super::DateTimePattern -/// [`TypedDateTimeNames`]: super::TypedDateTimeNames +/// [`FixedCalendarDateTimeNames`]: super::FixedCalendarDateTimeNames /// [`DateTimeFormatter`]: crate::DateTimeFormatter #[derive(Debug, Copy, Clone)] pub struct DateTimePatternFormatter<'a, C: CldrCalendar, FSet> { @@ -72,13 +72,13 @@ where /// use icu::datetime::pattern::DateTimePattern; /// use icu::datetime::pattern::MonthNameLength; /// use icu::datetime::pattern::YearNameLength; - /// use icu::datetime::pattern::TypedDateTimeNames; + /// use icu::datetime::pattern::FixedCalendarDateTimeNames; /// use icu::locale::locale; /// use writeable::assert_try_writeable_eq; /// /// // Create an instance that can format wide month and era names: - /// let mut names: TypedDateTimeNames = - /// TypedDateTimeNames::try_new(locale!("en-GB").into()).unwrap(); + /// let mut names: FixedCalendarDateTimeNames = + /// FixedCalendarDateTimeNames::try_new(locale!("en-GB").into()).unwrap(); /// names /// .include_month_names(MonthNameLength::Wide) /// .unwrap() @@ -110,14 +110,14 @@ where /// use icu::datetime::input::Time; /// use icu::datetime::fieldsets::enums::TimeFieldSet; /// use icu::datetime::pattern::DateTimePattern; - /// use icu::datetime::pattern::TypedDateTimeNames; + /// use icu::datetime::pattern::FixedCalendarDateTimeNames; /// use icu::datetime::pattern::DayPeriodNameLength; /// use icu::locale::locale; /// use writeable::assert_try_writeable_eq; /// /// // Create an instance that can format abbreviated day periods: - /// let mut names: TypedDateTimeNames = - /// TypedDateTimeNames::try_new(locale!("en-US").into()).unwrap(); + /// let mut names: FixedCalendarDateTimeNames = + /// FixedCalendarDateTimeNames::try_new(locale!("en-US").into()).unwrap(); /// names.include_day_period_names(DayPeriodNameLength::Abbreviated).unwrap(); /// /// // Create a pattern from a pattern string: @@ -155,7 +155,7 @@ where /// use icu::calendar::Gregorian; /// use icu::datetime::fieldsets::enums::ZoneFieldSet; /// use icu::datetime::pattern::DateTimePattern; - /// use icu::datetime::pattern::TypedDateTimeNames; + /// use icu::datetime::pattern::FixedCalendarDateTimeNames; /// use icu::locale::locale; /// use icu::datetime::input::ZonedDateTime; /// use icu::time::zone::{IanaParser, UtcOffsetCalculator}; @@ -166,7 +166,7 @@ where /// let mut london_summer = ZonedDateTime::try_from_str("2024-07-01T00:00:00+01:00[Europe/London]", Gregorian, IanaParser::new(), &UtcOffsetCalculator::new()) /// .unwrap(); /// - /// let mut names = TypedDateTimeNames::::try_new( + /// let mut names = FixedCalendarDateTimeNames::::try_new( /// locale!("en-GB").into(), /// ) /// .unwrap(); @@ -242,7 +242,8 @@ mod tests { #[test] fn test_basic_pattern_formatting() { let locale = locale!("en").into(); - let mut names: TypedDateTimeNames = TypedDateTimeNames::try_new(locale).unwrap(); + let mut names: FixedCalendarDateTimeNames = + FixedCalendarDateTimeNames::try_new(locale).unwrap(); names .load_month_names(&crate::provider::Baked, MonthNameLength::Wide) .unwrap() @@ -310,8 +311,8 @@ mod tests { length, expected, } = cas; - let mut names: TypedDateTimeNames = - TypedDateTimeNames::try_new(locale).unwrap(); + let mut names: FixedCalendarDateTimeNames = + FixedCalendarDateTimeNames::try_new(locale).unwrap(); names .load_year_names(&crate::provider::Baked, length) .unwrap(); @@ -376,8 +377,8 @@ mod tests { length, expected, } = cas; - let mut names: TypedDateTimeNames = - TypedDateTimeNames::try_new(locale).unwrap(); + let mut names: FixedCalendarDateTimeNames = + FixedCalendarDateTimeNames::try_new(locale).unwrap(); names .load_month_names(&crate::provider::Baked, length) .unwrap(); @@ -481,8 +482,8 @@ mod tests { length, expected, } = cas; - let mut names: TypedDateTimeNames = - TypedDateTimeNames::try_new(locale).unwrap(); + let mut names: FixedCalendarDateTimeNames = + FixedCalendarDateTimeNames::try_new(locale).unwrap(); names .load_weekday_names(&crate::provider::Baked, length) .unwrap(); @@ -566,8 +567,8 @@ mod tests { length, expected, } = cas; - let mut names: TypedDateTimeNames = - TypedDateTimeNames::try_new(locale).unwrap(); + let mut names: FixedCalendarDateTimeNames = + FixedCalendarDateTimeNames::try_new(locale).unwrap(); names .load_day_period_names(&crate::provider::Baked, length) .unwrap(); diff --git a/components/datetime/src/pattern/mod.rs b/components/datetime/src/pattern/mod.rs index 7d8b14bfc66..543ccdf45f9 100644 --- a/components/datetime/src/pattern/mod.rs +++ b/components/datetime/src/pattern/mod.rs @@ -21,11 +21,11 @@ pub use formatter::FormattedDateTimePattern; use icu_pattern::SinglePlaceholderPattern; pub use names::DateTimeNames; pub use names::DayPeriodNameLength; +pub use names::FixedCalendarDateTimeNames; pub use names::MonthNameLength; pub(crate) use names::RawDateTimeNames; pub(crate) use names::RawDateTimeNamesBorrowed; pub(crate) use names::TimeZoneDataPayloadsBorrowed; -pub use names::TypedDateTimeNames; pub use names::WeekdayNameLength; pub use names::YearNameLength; pub use pattern::DateTimePattern; @@ -64,7 +64,7 @@ pub(crate) enum MonthPlaceholderValue<'a> { NumericPattern(&'a SinglePlaceholderPattern), } -/// Error returned from [`TypedDateTimeNames`]'s pattern load methods. +/// Error returned from [`FixedCalendarDateTimeNames`]'s pattern load methods. #[derive(Debug, Clone, Copy, PartialEq, displaydoc::Display)] #[non_exhaustive] pub enum PatternLoadError { @@ -83,7 +83,7 @@ pub enum PatternLoadError { /// The specific type does not support this field. /// /// This happens for example when trying to load a month field - /// on a [`TypedDateTimeNames`]. + /// on a [`FixedCalendarDateTimeNames`]. #[displaydoc("The specific type does not support the field {0:?}.")] TypeTooSpecific(ErrorField), /// An error arising from the [`data provider`](icu_provider) for loading names. diff --git a/components/datetime/src/pattern/names.rs b/components/datetime/src/pattern/names.rs index 179f4b8b73c..50729a7704a 100644 --- a/components/datetime/src/pattern/names.rs +++ b/components/datetime/src/pattern/names.rs @@ -365,7 +365,7 @@ where } size_test!( - TypedDateTimeNames, + FixedCalendarDateTimeNames, typed_date_time_names_size, 312 ); @@ -393,7 +393,7 @@ size_test!( /// ``` /// use icu::calendar::Gregorian; /// use icu::calendar::Date; -/// use icu::datetime::pattern::TypedDateTimeNames; +/// use icu::datetime::pattern::FixedCalendarDateTimeNames; /// use icu::datetime::pattern::DateTimePattern; /// use icu::datetime::pattern::MonthNameLength; /// use icu::datetime::pattern::WeekdayNameLength; @@ -403,8 +403,8 @@ size_test!( /// use writeable::assert_try_writeable_eq; /// /// // Create an instance that can format abbreviated month, weekday, and day period names: -/// let mut names: TypedDateTimeNames = -/// TypedDateTimeNames::try_new(locale!("uk").into()).unwrap(); +/// let mut names: FixedCalendarDateTimeNames = +/// FixedCalendarDateTimeNames::try_new(locale!("uk").into()).unwrap(); /// names /// .include_month_names(MonthNameLength::Abbreviated) /// .unwrap() @@ -429,7 +429,7 @@ size_test!( /// use icu::calendar::Date; /// use icu::datetime::DateTimeWriteError; /// use icu::datetime::parts; -/// use icu::datetime::pattern::TypedDateTimeNames; +/// use icu::datetime::pattern::FixedCalendarDateTimeNames; /// use icu::datetime::pattern::{DateTimePattern, PatternLoadError}; /// use icu::datetime::fieldsets::enums::CompositeFieldSet; /// use icu::locale::locale; @@ -442,8 +442,8 @@ size_test!( /// use icu::datetime::provider::fields::{Field, FieldLength, FieldSymbol, Weekday}; /// /// // Create an instance that can format all fields (CompositeFieldSet): -/// let mut names: TypedDateTimeNames = -/// TypedDateTimeNames::try_new(locale!("en").into()).unwrap(); +/// let mut names: FixedCalendarDateTimeNames = +/// FixedCalendarDateTimeNames::try_new(locale!("en").into()).unwrap(); /// /// // Create a pattern from a pattern string: /// let pattern_str = "'It is:' E MMM d y G 'at' h:mm:ssSSS a zzzz"; @@ -499,7 +499,7 @@ size_test!( /// use icu::calendar::Gregorian; /// use icu::datetime::DateTimeWriteError; /// use icu::datetime::parts; -/// use icu::datetime::pattern::TypedDateTimeNames; +/// use icu::datetime::pattern::FixedCalendarDateTimeNames; /// use icu::datetime::pattern::DateTimePattern; /// use icu::datetime::fieldsets::zone::LocalizedOffsetLong; /// use icu::locale::locale; @@ -507,15 +507,15 @@ size_test!( /// use writeable::{Part, assert_try_writeable_parts_eq}; /// /// // Create an instance that can format abbreviated month, weekday, and day period names: -/// let mut names: TypedDateTimeNames = -/// TypedDateTimeNames::try_new(locale!("en").into()).unwrap(); +/// let mut names: FixedCalendarDateTimeNames = +/// FixedCalendarDateTimeNames::try_new(locale!("en").into()).unwrap(); /// /// // Create a pattern from a pattern string: /// let pattern_str = "'It is:' E MMM d y G 'at' h:mm:ssSSS a zzzz"; /// let pattern: DateTimePattern = pattern_str.parse().unwrap(); /// /// // The pattern string contains lots of symbols including "E", "MMM", and "a", -/// // but the `TypedDateTimeNames` is configured to format only time zones! +/// // but the `FixedCalendarDateTimeNames` is configured to format only time zones! /// // Further, the time zone we provide doesn't contain any offset into! /// // Missing data is filled in on a best-effort basis, and an error is signaled. /// assert_try_writeable_parts_eq!( @@ -547,7 +547,7 @@ size_test!( /// ); /// ``` #[derive(Debug)] -pub struct TypedDateTimeNames { +pub struct FixedCalendarDateTimeNames { prefs: DateTimeFormatterPreferences, inner: RawDateTimeNames, _calendar: PhantomData, @@ -561,7 +561,7 @@ pub struct TypedDateTimeNames #[derive(Debug)] pub struct DateTimeNames { - inner: TypedDateTimeNames<(), FSet>, + inner: FixedCalendarDateTimeNames<(), FSet>, calendar: AnyCalendar, } @@ -611,7 +611,7 @@ impl fmt::Debug for RawDateTimeNames { } impl RawDateTimeNames { - pub(crate) fn with_fset>(self) -> RawDateTimeNames { + pub(crate) fn cast_into_fset>(self) -> RawDateTimeNames { RawDateTimeNames { year_names: FSet2::map_year_names(self.year_names), month_names: FSet2::map_month_names(self.month_names), @@ -652,10 +652,10 @@ pub(crate) struct RawDateTimeNamesBorrowed<'l> { pub(crate) decimal_formatter: Option<&'l DecimalFormatter>, } -impl TypedDateTimeNames { +impl FixedCalendarDateTimeNames { /// Constructor that takes a selected locale and creates an empty instance. /// - /// For an example, see [`TypedDateTimeNames`]. + /// For an example, see [`FixedCalendarDateTimeNames`]. /// /// ✨ *Enabled with the `compiled_data` Cargo feature.* /// @@ -709,15 +709,15 @@ impl TypedDateTimeNames { /// use icu::calendar::Date; /// use icu::datetime::parts; /// use icu::datetime::DateTimeWriteError; - /// use icu::datetime::pattern::TypedDateTimeNames; + /// use icu::datetime::pattern::FixedCalendarDateTimeNames; /// use icu::datetime::pattern::DateTimePattern; /// use icu::datetime::fieldsets::enums::DateFieldSet; /// use icu::locale::locale; /// use writeable::{Part, assert_try_writeable_parts_eq}; /// /// // Create an instance that can format only date fields: - /// let names: TypedDateTimeNames = - /// TypedDateTimeNames::new_without_number_formatting(locale!("en").into()); + /// let names: FixedCalendarDateTimeNames = + /// FixedCalendarDateTimeNames::new_without_number_formatting(locale!("en").into()); /// /// // Create a pattern from a pattern string: /// let pattern_str = "'It is:' y-MM-dd"; @@ -753,7 +753,7 @@ impl TypedDateTimeNames { } } -impl TypedDateTimeNames { +impl FixedCalendarDateTimeNames { /// Creates an instance with the names loaded in a [`FixedCalendarDateTimeFormatter`]. /// /// This function requires passing in the [`DateTimeFormatterPreferences`] because it is not @@ -766,7 +766,7 @@ impl TypedDateTimeNames { /// use icu::datetime::input::{DateTime, Time}; /// use icu::datetime::FixedCalendarDateTimeFormatter; /// use icu::datetime::fieldsets::{YMD, YMDT}; - /// use icu::datetime::pattern::{TypedDateTimeNames, DayPeriodNameLength}; + /// use icu::datetime::pattern::{FixedCalendarDateTimeNames, DayPeriodNameLength}; /// use icu::locale::locale; /// use writeable::assert_writeable_eq; /// @@ -786,7 +786,7 @@ impl TypedDateTimeNames { /// /// // Change the YMD formatter to a YMDT formatter, after loading day period names. /// // This assumes that the locale uses Abbreviated names for the given semantic skeleton! - /// let mut names = TypedDateTimeNames::from_formatter(prefs, formatter).with_fset::(); + /// let mut names = FixedCalendarDateTimeNames::from_formatter(prefs, formatter).cast_into_fset::(); /// names.include_day_period_names(DayPeriodNameLength::Abbreviated).unwrap(); /// let formatter = names.try_into_formatter(YMDT::long().hm()).unwrap(); /// @@ -818,7 +818,7 @@ impl TypedDateTimeNames { } } -impl TypedDateTimeNames +impl FixedCalendarDateTimeNames where FSet::D: TypedDateDataMarkers, FSet::T: TimeMarkers, @@ -827,7 +827,7 @@ where { /// Loads a pattern for the given field set and returns a [`FixedCalendarDateTimeFormatter`]. /// - /// The names in the current [`TypedDateTimeNames`] _must_ be sufficient for the field set. + /// The names in the current [`FixedCalendarDateTimeNames`] _must_ be sufficient for the field set. /// If not, the input object will be returned with an error. /// /// # Examples @@ -835,11 +835,11 @@ where /// ``` /// use icu::datetime::input::Time; /// use icu::datetime::fieldsets::T; - /// use icu::datetime::pattern::{TypedDateTimeNames, DayPeriodNameLength}; + /// use icu::datetime::pattern::{FixedCalendarDateTimeNames, DayPeriodNameLength}; /// use icu::locale::locale; /// use writeable::assert_writeable_eq; /// - /// let names = TypedDateTimeNames::<(), _>::new_without_number_formatting( + /// let names = FixedCalendarDateTimeNames::<(), _>::new_without_number_formatting( /// locale!("es-MX").into(), /// ); /// @@ -931,7 +931,7 @@ impl DateTimeNames { calendar: AnyCalendar, ) -> Self { Self { - inner: TypedDateTimeNames::new_without_number_formatting(prefs), + inner: FixedCalendarDateTimeNames::new_without_number_formatting(prefs), calendar, } } @@ -968,7 +968,7 @@ impl DateTimeNames { /// /// // Change the YMD formatter to a YMDT formatter, after loading day period names. /// // This assumes that the locale uses Abbreviated names for the given semantic skeleton! - /// let mut names = DateTimeNames::from_formatter(prefs, formatter).with_fset::(); + /// let mut names = DateTimeNames::from_formatter(prefs, formatter).cast_into_fset::(); /// names.as_mut().include_day_period_names(DayPeriodNameLength::Abbreviated).unwrap(); /// let formatter = names.try_into_formatter(YMDT::long().hm()).unwrap(); /// @@ -992,7 +992,7 @@ impl DateTimeNames { parts: (AnyCalendar, RawDateTimeNames), ) -> Self { Self { - inner: TypedDateTimeNames { + inner: FixedCalendarDateTimeNames { prefs, inner: parts.1, _calendar: PhantomData, @@ -1113,19 +1113,23 @@ where } } -impl AsRef> for DateTimeNames { - fn as_ref(&self) -> &TypedDateTimeNames<(), FSet> { +impl AsRef> + for DateTimeNames +{ + fn as_ref(&self) -> &FixedCalendarDateTimeNames<(), FSet> { &self.inner } } -impl AsMut> for DateTimeNames { - fn as_mut(&mut self) -> &mut TypedDateTimeNames<(), FSet> { +impl AsMut> + for DateTimeNames +{ + fn as_mut(&mut self) -> &mut FixedCalendarDateTimeNames<(), FSet> { &mut self.inner } } -impl TypedDateTimeNames { +impl FixedCalendarDateTimeNames { /// Loads year (era or cycle) names for the specified length. /// /// Does not support multiple field symbols or lengths. See #4337 @@ -1156,11 +1160,11 @@ impl TypedDateTimeNames { /// use icu::calendar::Gregorian; /// use icu::datetime::pattern::PatternLoadError; /// use icu::datetime::pattern::YearNameLength; - /// use icu::datetime::pattern::TypedDateTimeNames; + /// use icu::datetime::pattern::FixedCalendarDateTimeNames; /// use icu::locale::locale; /// /// let mut names = - /// TypedDateTimeNames::::try_new(locale!("und").into()) + /// FixedCalendarDateTimeNames::::try_new(locale!("und").into()) /// .unwrap(); /// /// // First length is successful: @@ -1216,11 +1220,11 @@ impl TypedDateTimeNames { /// use icu::calendar::Gregorian; /// use icu::datetime::pattern::MonthNameLength; /// use icu::datetime::pattern::PatternLoadError; - /// use icu::datetime::pattern::TypedDateTimeNames; + /// use icu::datetime::pattern::FixedCalendarDateTimeNames; /// use icu::locale::locale; /// /// let mut names = - /// TypedDateTimeNames::::try_new(locale!("und").into()) + /// FixedCalendarDateTimeNames::::try_new(locale!("und").into()) /// .unwrap(); /// /// // First length is successful: @@ -1255,7 +1259,7 @@ impl TypedDateTimeNames { } } -impl TypedDateTimeNames { +impl FixedCalendarDateTimeNames { /// Loads day period names for the specified length. /// /// Does not support multiple field symbols or lengths. See #4337 @@ -1287,11 +1291,11 @@ impl TypedDateTimeNames { /// use icu::calendar::Gregorian; /// use icu::datetime::pattern::DayPeriodNameLength; /// use icu::datetime::pattern::PatternLoadError; - /// use icu::datetime::pattern::TypedDateTimeNames; + /// use icu::datetime::pattern::FixedCalendarDateTimeNames; /// use icu::locale::locale; /// /// let mut names = - /// TypedDateTimeNames::::try_new(locale!("und").into()) + /// FixedCalendarDateTimeNames::::try_new(locale!("und").into()) /// .unwrap(); /// /// // First length is successful: @@ -1344,11 +1348,11 @@ impl TypedDateTimeNames { /// use icu::calendar::Gregorian; /// use icu::datetime::pattern::PatternLoadError; /// use icu::datetime::pattern::WeekdayNameLength; - /// use icu::datetime::pattern::TypedDateTimeNames; + /// use icu::datetime::pattern::FixedCalendarDateTimeNames; /// use icu::locale::locale; /// /// let mut names = - /// TypedDateTimeNames::::try_new(locale!("und").into()) + /// FixedCalendarDateTimeNames::::try_new(locale!("und").into()) /// .unwrap(); /// /// // First length is successful: @@ -1403,7 +1407,7 @@ impl TypedDateTimeNames { /// use icu::calendar::Gregorian; /// use icu::datetime::fieldsets::enums::ZoneFieldSet; /// use icu::datetime::pattern::DateTimePattern; - /// use icu::datetime::pattern::TypedDateTimeNames; + /// use icu::datetime::pattern::FixedCalendarDateTimeNames; /// use icu::locale::locale; /// use icu::time::zone::{IanaParser, UtcOffsetCalculator}; /// use icu::datetime::input::ZonedDateTime; @@ -1416,7 +1420,7 @@ impl TypedDateTimeNames { /// .unwrap() /// .zone; /// - /// let mut names = TypedDateTimeNames::::try_new( + /// let mut names = FixedCalendarDateTimeNames::::try_new( /// locale!("en-GB").into(), /// ) /// .unwrap(); @@ -1505,8 +1509,8 @@ impl TypedDateTimeNames { /// Important: When performing manual time zone data loading, in addition to the /// specific time zone format data, also call either: /// - /// - [`TypedDateTimeNames::include_time_zone_essentials`] - /// - [`TypedDateTimeNames::load_time_zone_essentials`] + /// - [`FixedCalendarDateTimeNames::include_time_zone_essentials`] + /// - [`FixedCalendarDateTimeNames::load_time_zone_essentials`] /// /// # Examples /// @@ -1514,7 +1518,7 @@ impl TypedDateTimeNames { /// use icu::calendar::Gregorian; /// use icu::datetime::fieldsets::enums::ZoneFieldSet; /// use icu::datetime::pattern::DateTimePattern; - /// use icu::datetime::pattern::TypedDateTimeNames; + /// use icu::datetime::pattern::FixedCalendarDateTimeNames; /// use icu::locale::locale; /// use icu::time::zone::{IanaParser, UtcOffsetCalculator}; /// use icu::datetime::input::ZonedDateTime; @@ -1524,7 +1528,7 @@ impl TypedDateTimeNames { /// .unwrap() /// .zone; /// - /// let mut names = TypedDateTimeNames::::try_new( + /// let mut names = FixedCalendarDateTimeNames::::try_new( /// locale!("en-GB").into(), /// ) /// .unwrap(); @@ -1569,8 +1573,8 @@ impl TypedDateTimeNames { /// Important: The `VVV` format requires location data in addition to exemplar /// city data. Also call either: /// - /// - [`TypedDateTimeNames::include_time_zone_location_names`] - /// - [`TypedDateTimeNames::load_time_zone_location_names`] + /// - [`FixedCalendarDateTimeNames::include_time_zone_location_names`] + /// - [`FixedCalendarDateTimeNames::load_time_zone_location_names`] /// /// # Examples /// @@ -1578,7 +1582,7 @@ impl TypedDateTimeNames { /// use icu::calendar::Gregorian; /// use icu::datetime::fieldsets::enums::ZoneFieldSet; /// use icu::datetime::pattern::DateTimePattern; - /// use icu::datetime::pattern::TypedDateTimeNames; + /// use icu::datetime::pattern::FixedCalendarDateTimeNames; /// use icu::locale::locale; /// use icu::time::zone::{IanaParser, UtcOffsetCalculator}; /// use icu::datetime::input::ZonedDateTime; @@ -1588,7 +1592,7 @@ impl TypedDateTimeNames { /// .unwrap() /// .zone; /// - /// let mut names = TypedDateTimeNames::::try_new( + /// let mut names = FixedCalendarDateTimeNames::::try_new( /// locale!("en-GB").into(), /// ) /// .unwrap(); @@ -1633,8 +1637,8 @@ impl TypedDateTimeNames { /// Important: When performing manual time zone data loading, in addition to the /// specific time zone format data, also call either: /// - /// - [`TypedDateTimeNames::include_time_zone_essentials`] - /// - [`TypedDateTimeNames::load_time_zone_essentials`] + /// - [`FixedCalendarDateTimeNames::include_time_zone_essentials`] + /// - [`FixedCalendarDateTimeNames::load_time_zone_essentials`] /// /// # Examples /// @@ -1642,7 +1646,7 @@ impl TypedDateTimeNames { /// use icu::calendar::Gregorian; /// use icu::datetime::fieldsets::enums::ZoneFieldSet; /// use icu::datetime::pattern::DateTimePattern; - /// use icu::datetime::pattern::TypedDateTimeNames; + /// use icu::datetime::pattern::FixedCalendarDateTimeNames; /// use icu::locale::locale; /// use icu::time::zone::{IanaParser, UtcOffsetCalculator}; /// use icu::datetime::input::ZonedDateTime; @@ -1655,7 +1659,7 @@ impl TypedDateTimeNames { /// .unwrap() /// .zone; /// - /// let mut names = TypedDateTimeNames::::try_new( + /// let mut names = FixedCalendarDateTimeNames::::try_new( /// locale!("en-GB").into(), /// ) /// .unwrap(); @@ -1706,8 +1710,8 @@ impl TypedDateTimeNames { /// Important: When performing manual time zone data loading, in addition to the /// specific time zone format data, also call either: /// - /// - [`TypedDateTimeNames::include_time_zone_essentials`] - /// - [`TypedDateTimeNames::load_time_zone_essentials`] + /// - [`FixedCalendarDateTimeNames::include_time_zone_essentials`] + /// - [`FixedCalendarDateTimeNames::load_time_zone_essentials`] /// /// # Examples /// @@ -1715,7 +1719,7 @@ impl TypedDateTimeNames { /// use icu::calendar::Gregorian; /// use icu::datetime::fieldsets::enums::ZoneFieldSet; /// use icu::datetime::pattern::DateTimePattern; - /// use icu::datetime::pattern::TypedDateTimeNames; + /// use icu::datetime::pattern::FixedCalendarDateTimeNames; /// use icu::locale::locale; /// use icu::time::zone::{IanaParser, UtcOffsetCalculator}; /// use icu::datetime::input::ZonedDateTime; @@ -1728,7 +1732,7 @@ impl TypedDateTimeNames { /// .unwrap() /// .zone; /// - /// let mut names = TypedDateTimeNames::::try_new( + /// let mut names = FixedCalendarDateTimeNames::::try_new( /// locale!("en-GB").into(), /// ) /// .unwrap(); @@ -1779,8 +1783,8 @@ impl TypedDateTimeNames { /// Important: When performing manual time zone data loading, in addition to the /// specific time zone format data, also call either: /// - /// - [`TypedDateTimeNames::include_time_zone_essentials`] - /// - [`TypedDateTimeNames::load_time_zone_essentials`] + /// - [`FixedCalendarDateTimeNames::include_time_zone_essentials`] + /// - [`FixedCalendarDateTimeNames::load_time_zone_essentials`] /// /// # Examples /// @@ -1788,7 +1792,7 @@ impl TypedDateTimeNames { /// use icu::calendar::Gregorian; /// use icu::datetime::fieldsets::enums::ZoneFieldSet; /// use icu::datetime::pattern::DateTimePattern; - /// use icu::datetime::pattern::TypedDateTimeNames; + /// use icu::datetime::pattern::FixedCalendarDateTimeNames; /// use icu::locale::locale; /// use icu::time::zone::{IanaParser, UtcOffsetCalculator}; /// use icu::datetime::input::ZonedDateTime; @@ -1801,7 +1805,7 @@ impl TypedDateTimeNames { /// .unwrap() /// .zone; /// - /// let mut names = TypedDateTimeNames::::try_new( + /// let mut names = FixedCalendarDateTimeNames::::try_new( /// locale!("en-GB").into(), /// ) /// .unwrap(); @@ -1852,8 +1856,8 @@ impl TypedDateTimeNames { /// Important: When performing manual time zone data loading, in addition to the /// specific time zone format data, also call either: /// - /// - [`TypedDateTimeNames::include_time_zone_essentials`] - /// - [`TypedDateTimeNames::load_time_zone_essentials`] + /// - [`FixedCalendarDateTimeNames::include_time_zone_essentials`] + /// - [`FixedCalendarDateTimeNames::load_time_zone_essentials`] /// /// # Examples /// @@ -1861,7 +1865,7 @@ impl TypedDateTimeNames { /// use icu::calendar::Gregorian; /// use icu::datetime::fieldsets::enums::ZoneFieldSet; /// use icu::datetime::pattern::DateTimePattern; - /// use icu::datetime::pattern::TypedDateTimeNames; + /// use icu::datetime::pattern::FixedCalendarDateTimeNames; /// use icu::locale::locale; /// use icu::time::zone::{IanaParser, UtcOffsetCalculator}; /// use icu::datetime::input::ZonedDateTime; @@ -1874,7 +1878,7 @@ impl TypedDateTimeNames { /// .unwrap() /// .zone; /// - /// let mut names = TypedDateTimeNames::::try_new( + /// let mut names = FixedCalendarDateTimeNames::::try_new( /// locale!("en-GB").into(), /// ) /// .unwrap(); @@ -1925,12 +1929,12 @@ impl TypedDateTimeNames { /// use icu::datetime::input::Time; /// use icu::datetime::fieldsets::enums::TimeFieldSet; /// use icu::datetime::pattern::DateTimePattern; - /// use icu::datetime::pattern::TypedDateTimeNames; + /// use icu::datetime::pattern::FixedCalendarDateTimeNames; /// use icu::locale::locale; /// use writeable::assert_try_writeable_eq; /// /// let mut names = - /// TypedDateTimeNames::<(), TimeFieldSet>::try_new(locale!("bn").into()) + /// FixedCalendarDateTimeNames::<(), TimeFieldSet>::try_new(locale!("bn").into()) /// .unwrap(); /// names.include_decimal_formatter(); /// @@ -1954,8 +1958,8 @@ impl TypedDateTimeNames { } } -impl TypedDateTimeNames { - /// Associates this [`TypedDateTimeNames`] with a pattern +impl FixedCalendarDateTimeNames { + /// Associates this [`FixedCalendarDateTimeNames`] with a pattern /// without checking that all necessary data is loaded. #[inline] pub fn with_pattern_unchecked<'l>( @@ -1965,7 +1969,7 @@ impl TypedDateTimeNames { DateTimePatternFormatter::new(pattern.as_borrowed(), self.inner.as_borrowed()) } - /// Associates this [`TypedDateTimeNames`] with a datetime pattern + /// Associates this [`FixedCalendarDateTimeNames`] with a datetime pattern /// and loads all data required for that pattern. /// /// Does not duplicate textual field symbols. See #4337 @@ -2020,7 +2024,7 @@ impl TypedDateTimeNames { )) } - /// Associates this [`TypedDateTimeNames`] with a pattern + /// Associates this [`FixedCalendarDateTimeNames`] with a pattern /// and includes all data required for that pattern. /// /// Does not support duplicate textual field symbols. See #4337 @@ -2030,13 +2034,13 @@ impl TypedDateTimeNames { /// ``` /// use icu::calendar::{Date, Gregorian}; /// use icu::datetime::pattern::DateTimePattern; - /// use icu::datetime::pattern::TypedDateTimeNames; + /// use icu::datetime::pattern::FixedCalendarDateTimeNames; /// use icu::locale::locale; /// use icu::datetime::input::{DateTime, Time}; /// use writeable::assert_try_writeable_eq; /// /// let mut names = - /// TypedDateTimeNames::::try_new(locale!("en").into()).unwrap(); + /// FixedCalendarDateTimeNames::::try_new(locale!("en").into()).unwrap(); /// /// // Create a pattern from a pattern string: /// let pattern_str = "MMM d (EEEE) 'of year' y G 'at' h:mm a"; @@ -2089,8 +2093,8 @@ impl TypedDateTimeNames { } } -impl TypedDateTimeNames { - /// Maps a [`TypedDateTimeNames`] of a specific `FSet` to a more general `FSet`. +impl FixedCalendarDateTimeNames { + /// Maps a [`FixedCalendarDateTimeNames`] of a specific `FSet` to a more general `FSet`. /// /// For example, this can transform a formatter for [`DateFieldSet`] to one for /// [`CompositeDateTimeFieldSet`]. @@ -2103,7 +2107,7 @@ impl TypedDateTimeNames { /// ``` /// use icu::calendar::Gregorian; /// use icu::calendar::Date; - /// use icu::datetime::pattern::TypedDateTimeNames; + /// use icu::datetime::pattern::FixedCalendarDateTimeNames; /// use icu::datetime::pattern::MonthNameLength; /// use icu::datetime::fieldsets::enums::{DateFieldSet, CompositeDateTimeFieldSet}; /// use icu::datetime::pattern::DateTimePattern; @@ -2112,8 +2116,8 @@ impl TypedDateTimeNames { /// use writeable::assert_try_writeable_eq; /// /// // Create an instance that can format abbreviated month names: - /// let mut names: TypedDateTimeNames = - /// TypedDateTimeNames::try_new(locale!("uk").into()).unwrap(); + /// let mut names: FixedCalendarDateTimeNames = + /// FixedCalendarDateTimeNames::try_new(locale!("uk").into()).unwrap(); /// names /// .include_month_names(MonthNameLength::Abbreviated) /// .unwrap(); @@ -2125,7 +2129,7 @@ impl TypedDateTimeNames { /// assert_try_writeable_eq!(names.with_pattern_unchecked(&pattern).format(&datetime), "лист. 20 2023"); /// /// // Convert the field set to `CompositeDateTimeFieldSet`: - /// let composite_names = names.with_fset::(); + /// let composite_names = names.cast_into_fset::(); /// /// // It should still work: /// assert_try_writeable_eq!(composite_names.with_pattern_unchecked(&pattern).format(&datetime), "лист. 20 2023"); @@ -2135,34 +2139,36 @@ impl TypedDateTimeNames { /// /// ```compile_fail,E0277 /// use icu::calendar::Gregorian; - /// use icu::datetime::pattern::TypedDateTimeNames; + /// use icu::datetime::pattern::FixedCalendarDateTimeNames; /// use icu::datetime::fieldsets::enums::{DateFieldSet, CompositeDateTimeFieldSet}; /// - /// let composite_names: TypedDateTimeNames = todo!(); + /// let composite_names: FixedCalendarDateTimeNames = todo!(); /// /// // error[E0277]: the trait bound `(): From>` is not satisfied - /// let narrow_names = composite_names.with_fset::(); + /// let narrow_names = composite_names.cast_into_fset::(); /// ``` - pub fn with_fset>(self) -> TypedDateTimeNames { - TypedDateTimeNames { + pub fn cast_into_fset>( + self, + ) -> FixedCalendarDateTimeNames { + FixedCalendarDateTimeNames { prefs: self.prefs, - inner: self.inner.with_fset(), + inner: self.inner.cast_into_fset(), _calendar: PhantomData, } } } impl DateTimeNames { - /// Maps a [`TypedDateTimeNames`] of a specific `FSet` to a more general `FSet`. + /// Maps a [`FixedCalendarDateTimeNames`] of a specific `FSet` to a more general `FSet`. /// /// For example, this can transform a formatter for [`DateFieldSet`] to one for /// [`CompositeDateTimeFieldSet`]. /// /// [`DateFieldSet`]: crate::fieldsets::enums::DateFieldSet /// [`CompositeDateTimeFieldSet`]: crate::fieldsets::enums::CompositeDateTimeFieldSet - pub fn with_fset>(self) -> DateTimeNames { + pub fn cast_into_fset>(self) -> DateTimeNames { DateTimeNames { - inner: self.inner.with_fset(), + inner: self.inner.cast_into_fset(), calendar: self.calendar, } } diff --git a/components/datetime/src/pattern/pattern.rs b/components/datetime/src/pattern/pattern.rs index 436cd0f408a..7aefe73eb2e 100644 --- a/components/datetime/src/pattern/pattern.rs +++ b/components/datetime/src/pattern/pattern.rs @@ -24,7 +24,7 @@ size_test!(DateTimePattern, date_time_pattern_size, 32); /// /// Things you can do with one of these: /// -/// 1. Use it to directly format a datetime via [`TypedDateTimeNames`] +/// 1. Use it to directly format a datetime via [`FixedCalendarDateTimeNames`] /// 2. Convert it to a string pattern via [`Writeable`] /// 3. Get the resolved components #[doc = date_time_pattern_size!()] @@ -104,7 +104,7 @@ size_test!(DateTimePattern, date_time_pattern_size, 32); /// /// [`DateTimeFormatter`]: crate::DateTimeFormatter /// [`FormattedDateTime::pattern`]: crate::FormattedDateTime::pattern -/// [`TypedDateTimeNames`]: crate::pattern::TypedDateTimeNames +/// [`FixedCalendarDateTimeNames`]: crate::pattern::FixedCalendarDateTimeNames #[derive(Debug)] pub struct DateTimePattern { pattern: runtime::Pattern<'static>, diff --git a/components/datetime/src/scaffold/names_storage.rs b/components/datetime/src/scaffold/names_storage.rs index 889fffbf779..9b1edf0b9c2 100644 --- a/components/datetime/src/scaffold/names_storage.rs +++ b/components/datetime/src/scaffold/names_storage.rs @@ -154,7 +154,7 @@ where } } -// NOTE: This impl enables `with_fset` functions to work. +// NOTE: This impl enables `cast_into_fset` functions to work. impl From<()> for DataPayloadWithVariables { #[inline] fn from(_: ()) -> Self { diff --git a/components/datetime/tests/datetime.rs b/components/datetime/tests/datetime.rs index ea825a5e716..893706aa26e 100644 --- a/components/datetime/tests/datetime.rs +++ b/components/datetime/tests/datetime.rs @@ -18,7 +18,7 @@ use icu_calendar::{ use icu_datetime::scaffold::CldrCalendar; use icu_datetime::{fieldsets::enums::*, DateTimeFormatterPreferences}; use icu_datetime::{ - pattern::DateTimePattern, pattern::TypedDateTimeNames, DateTimeFormatter, + pattern::DateTimePattern, pattern::FixedCalendarDateTimeNames, DateTimeFormatter, FixedCalendarDateTimeFormatter, }; use icu_locale_core::{ @@ -385,11 +385,13 @@ fn test_dayperiod_patterns() { for pattern_input in patterns { let parsed_pattern = DateTimePattern::try_from_pattern_str(pattern_input).unwrap(); - let mut pattern_formatter = - TypedDateTimeNames::::try_new( - (&locale).into(), - ) - .unwrap(); + let mut pattern_formatter = FixedCalendarDateTimeNames::< + Gregorian, + CompositeDateTimeFieldSet, + >::try_new( + (&locale).into() + ) + .unwrap(); let formatted_datetime = pattern_formatter .include_for_pattern(&parsed_pattern) .unwrap() @@ -492,7 +494,7 @@ fn test_time_zone_patterns() { } let parsed_pattern = DateTimePattern::try_from_pattern_str(pattern_input).unwrap(); let mut pattern_formatter = - TypedDateTimeNames::::try_new(prefs).unwrap(); + FixedCalendarDateTimeNames::::try_new(prefs).unwrap(); let formatted_datetime = pattern_formatter .include_for_pattern(&parsed_pattern) .unwrap() diff --git a/ffi/capi/src/neo_datetime.rs b/ffi/capi/src/neo_datetime.rs index 37aef132e10..a393b7031c5 100644 --- a/ffi/capi/src/neo_datetime.rs +++ b/ffi/capi/src/neo_datetime.rs @@ -89,7 +89,7 @@ pub mod ffi { .with_alignment(map_or_default(alignment)) .with_time_precision(map_or_default(time_precision)); Ok(Box::new(DateTimeFormatter( - icu_datetime::DateTimeFormatter::try_new(prefs, options)?.with_fset(), + icu_datetime::DateTimeFormatter::try_new(prefs, options)?.cast_into_fset(), ))) } @@ -121,7 +121,7 @@ pub mod ffi { prefs, options, )? - .with_fset(), + .cast_into_fset(), ))) } @@ -150,7 +150,7 @@ pub mod ffi { .with_alignment(map_or_default(alignment)) .with_time_precision(map_or_default(time_precision)); Ok(Box::new(DateTimeFormatter( - icu_datetime::DateTimeFormatter::try_new(prefs, options)?.with_fset(), + icu_datetime::DateTimeFormatter::try_new(prefs, options)?.cast_into_fset(), ))) } @@ -181,7 +181,7 @@ pub mod ffi { prefs, options, )? - .with_fset(), + .cast_into_fset(), ))) } @@ -214,7 +214,7 @@ pub mod ffi { .with_time_precision(map_or_default(time_precision)) .with_year_style(map_or_default(year_style)); Ok(Box::new(DateTimeFormatter( - icu_datetime::DateTimeFormatter::try_new(prefs, options)?.with_fset(), + icu_datetime::DateTimeFormatter::try_new(prefs, options)?.cast_into_fset(), ))) } @@ -248,7 +248,7 @@ pub mod ffi { prefs, options, )? - .with_fset(), + .cast_into_fset(), ))) } @@ -277,7 +277,7 @@ pub mod ffi { .with_alignment(map_or_default(alignment)) .with_time_precision(map_or_default(time_precision)); Ok(Box::new(DateTimeFormatter( - icu_datetime::DateTimeFormatter::try_new(prefs, options)?.with_fset(), + icu_datetime::DateTimeFormatter::try_new(prefs, options)?.cast_into_fset(), ))) } @@ -308,7 +308,7 @@ pub mod ffi { prefs, options, )? - .with_fset(), + .cast_into_fset(), ))) } @@ -337,7 +337,7 @@ pub mod ffi { .with_alignment(map_or_default(alignment)) .with_time_precision(map_or_default(time_precision)); Ok(Box::new(DateTimeFormatter( - icu_datetime::DateTimeFormatter::try_new(prefs, options)?.with_fset(), + icu_datetime::DateTimeFormatter::try_new(prefs, options)?.cast_into_fset(), ))) } @@ -368,7 +368,7 @@ pub mod ffi { prefs, options, )? - .with_fset(), + .cast_into_fset(), ))) } @@ -404,7 +404,7 @@ pub mod ffi { .with_time_precision(map_or_default(time_precision)) .with_year_style(map_or_default(year_style)); Ok(Box::new(DateTimeFormatter( - icu_datetime::DateTimeFormatter::try_new(prefs, options)?.with_fset(), + icu_datetime::DateTimeFormatter::try_new(prefs, options)?.cast_into_fset(), ))) } @@ -442,7 +442,7 @@ pub mod ffi { prefs, options, )? - .with_fset(), + .cast_into_fset(), ))) } @@ -471,7 +471,7 @@ pub mod ffi { .with_alignment(map_or_default(alignment)) .with_time_precision(map_or_default(time_precision)); Ok(Box::new(DateTimeFormatter( - icu_datetime::DateTimeFormatter::try_new(prefs, options)?.with_fset(), + icu_datetime::DateTimeFormatter::try_new(prefs, options)?.cast_into_fset(), ))) } @@ -502,7 +502,7 @@ pub mod ffi { prefs, options, )? - .with_fset(), + .cast_into_fset(), ))) } @@ -572,7 +572,8 @@ pub mod ffi { .with_alignment(map_or_default(alignment)) .with_time_precision(map_or_default(time_precision)); Ok(Box::new(DateTimeFormatterGregorian( - icu_datetime::FixedCalendarDateTimeFormatter::try_new(prefs, options)?.with_fset(), + icu_datetime::FixedCalendarDateTimeFormatter::try_new(prefs, options)? + .cast_into_fset(), ))) } @@ -604,7 +605,7 @@ pub mod ffi { prefs, options, )? - .with_fset(), + .cast_into_fset(), ))) } @@ -633,7 +634,8 @@ pub mod ffi { .with_alignment(map_or_default(alignment)) .with_time_precision(map_or_default(time_precision)); Ok(Box::new(DateTimeFormatterGregorian( - icu_datetime::FixedCalendarDateTimeFormatter::try_new(prefs, options)?.with_fset(), + icu_datetime::FixedCalendarDateTimeFormatter::try_new(prefs, options)? + .cast_into_fset(), ))) } @@ -664,7 +666,7 @@ pub mod ffi { prefs, options, )? - .with_fset(), + .cast_into_fset(), ))) } @@ -697,7 +699,8 @@ pub mod ffi { .with_time_precision(map_or_default(time_precision)) .with_year_style(map_or_default(year_style)); Ok(Box::new(DateTimeFormatterGregorian( - icu_datetime::FixedCalendarDateTimeFormatter::try_new(prefs, options)?.with_fset(), + icu_datetime::FixedCalendarDateTimeFormatter::try_new(prefs, options)? + .cast_into_fset(), ))) } @@ -731,7 +734,7 @@ pub mod ffi { prefs, options, )? - .with_fset(), + .cast_into_fset(), ))) } @@ -760,7 +763,8 @@ pub mod ffi { .with_alignment(map_or_default(alignment)) .with_time_precision(map_or_default(time_precision)); Ok(Box::new(DateTimeFormatterGregorian( - icu_datetime::FixedCalendarDateTimeFormatter::try_new(prefs, options)?.with_fset(), + icu_datetime::FixedCalendarDateTimeFormatter::try_new(prefs, options)? + .cast_into_fset(), ))) } @@ -791,7 +795,7 @@ pub mod ffi { prefs, options, )? - .with_fset(), + .cast_into_fset(), ))) } @@ -820,7 +824,8 @@ pub mod ffi { .with_alignment(map_or_default(alignment)) .with_time_precision(map_or_default(time_precision)); Ok(Box::new(DateTimeFormatterGregorian( - icu_datetime::FixedCalendarDateTimeFormatter::try_new(prefs, options)?.with_fset(), + icu_datetime::FixedCalendarDateTimeFormatter::try_new(prefs, options)? + .cast_into_fset(), ))) } @@ -851,7 +856,7 @@ pub mod ffi { prefs, options, )? - .with_fset(), + .cast_into_fset(), ))) } @@ -887,7 +892,8 @@ pub mod ffi { .with_time_precision(map_or_default(time_precision)) .with_year_style(map_or_default(year_style)); Ok(Box::new(DateTimeFormatterGregorian( - icu_datetime::FixedCalendarDateTimeFormatter::try_new(prefs, options)?.with_fset(), + icu_datetime::FixedCalendarDateTimeFormatter::try_new(prefs, options)? + .cast_into_fset(), ))) } @@ -925,7 +931,7 @@ pub mod ffi { prefs, options, )? - .with_fset(), + .cast_into_fset(), ))) } @@ -954,7 +960,8 @@ pub mod ffi { .with_alignment(map_or_default(alignment)) .with_time_precision(map_or_default(time_precision)); Ok(Box::new(DateTimeFormatterGregorian( - icu_datetime::FixedCalendarDateTimeFormatter::try_new(prefs, options)?.with_fset(), + icu_datetime::FixedCalendarDateTimeFormatter::try_new(prefs, options)? + .cast_into_fset(), ))) } @@ -985,7 +992,7 @@ pub mod ffi { prefs, options, )? - .with_fset(), + .cast_into_fset(), ))) } diff --git a/tools/make/diplomat-coverage/src/allowlist.rs b/tools/make/diplomat-coverage/src/allowlist.rs index ac317730b7f..6a37c5e4499 100644 --- a/tools/make/diplomat-coverage/src/allowlist.rs +++ b/tools/make/diplomat-coverage/src/allowlist.rs @@ -338,8 +338,8 @@ lazy_static::lazy_static! { "icu::calendar::AsCalendar", "icu::calendar::Ref", "icu::datetime::CldrCalendar", - "icu::datetime::DateTimeFormatter::with_fset", - "icu::datetime::FixedCalendarDateTimeFormatter::with_fset", + "icu::datetime::DateTimeFormatter::cast_into_fset", + "icu::datetime::FixedCalendarDateTimeFormatter::cast_into_fset", // TODO-2.0: needs investigation "icu::calendar::Date::wrap_calendar_in_rc", "icu::calendar::Date::wrap_calendar_in_arc",