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

Compiled constructor docs #3742

Merged
merged 2 commits into from
Aug 7, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
4 changes: 2 additions & 2 deletions components/calendar/src/any_calendar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@ impl Calendar for AnyCalendar {
}

impl AnyCalendar {
/// Constructs an AnyCalendar for a given calendar kind.
/// Constructs an AnyCalendar for a given calendar kind from compiled data.
///
/// As this requires a valid [`AnyCalendarKind`] to work, it does not do any kind of locale-based
/// fallbacking. If this is desired, use [`Self::new_for_locale()`].
Expand Down Expand Up @@ -545,7 +545,7 @@ impl AnyCalendar {
})
}

/// Constructs an AnyCalendar for a given calendar kind.
/// Constructs an AnyCalendar for a given calendar kind from compiled data.
///
/// In case the locale's calendar is unknown or unspecified, it will attempt to load the default
/// calendar for the locale, falling back to gregorian.
Expand Down
15 changes: 6 additions & 9 deletions components/calendar/src/japanese.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ pub struct JapaneseDateInner {
}

impl Japanese {
/// Creates a new [`Japanese`] using only modern eras (post-meiji).
/// Creates a new [`Japanese`] using only modern eras (post-meiji) from compiled data.
///
/// ✨ *Enabled with the `compiled_data` Cargo feature.*
///
Expand All @@ -136,10 +136,10 @@ impl Japanese {

#[doc = icu_provider::gen_any_buffer_unstable_docs!(UNSTABLE, Self::new)]
pub fn try_new_unstable<D: DataProvider<JapaneseErasV1Marker> + ?Sized>(
data_provider: &D,
provider: &D,
) -> Result<Self, CalendarError> {
Ok(Self {
eras: data_provider.load(Default::default())?.take_payload()?,
eras: provider.load(Default::default())?.take_payload()?,
})
}

Expand Down Expand Up @@ -167,7 +167,7 @@ impl Japanese {
}

impl JapaneseExtended {
/// Creates a new [`Japanese`] from using all eras (including pre-meiji).
/// Creates a new [`Japanese`] from using all eras (including pre-meiji) from compiled data.
///
/// ✨ *Enabled with the `compiled_data` Cargo feature.*
///
Expand All @@ -193,13 +193,10 @@ impl JapaneseExtended {

#[doc = icu_provider::gen_any_buffer_unstable_docs!(UNSTABLE, Self::new)]
pub fn try_new_unstable<D: DataProvider<JapaneseExtendedErasV1Marker> + ?Sized>(
data_provider: &D,
provider: &D,
) -> Result<Self, CalendarError> {
Ok(Self(Japanese {
eras: data_provider
.load(Default::default())?
.take_payload()?
.cast(),
eras: provider.load(Default::default())?.take_payload()?.cast(),
}))
}
}
Expand Down
2 changes: 1 addition & 1 deletion components/calendar/src/week_of.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ impl WeekCalculator {
locale: include,
options: skip,
error: CalendarError,
/// Creates a new [`WeekCalculator`] from locale data.
/// Creates a new [`WeekCalculator`] from compiled locale data.
);

#[doc = icu_provider::gen_any_buffer_unstable_docs!(UNSTABLE, Self::try_new)]
Expand Down
26 changes: 13 additions & 13 deletions components/collator/src/comparison.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ pub struct Collator {
}

impl Collator {
/// Instantiates a collator for a given locale with the given options
/// Creates a collator for the given locale and options from compiled data.
#[cfg(feature = "compiled_data")]
pub fn try_new(locale: &DataLocale, options: CollatorOptions) -> Result<Self, CollatorError> {
Self::try_new_unstable_internal(
Expand Down Expand Up @@ -99,7 +99,7 @@ impl Collator {

#[doc = icu_provider::gen_any_buffer_unstable_docs!(UNSTABLE, Self::try_new)]
pub fn try_new_unstable<D>(
data_provider: &D,
provider: &D,
locale: &DataLocale,
options: CollatorOptions,
) -> Result<Self, CollatorError>
Expand All @@ -115,18 +115,18 @@ impl Collator {
+ ?Sized,
{
Self::try_new_unstable_internal(
data_provider,
data_provider.load(Default::default())?.take_payload()?,
data_provider.load(Default::default())?.take_payload()?,
data_provider.load(Default::default())?.take_payload()?,
|| data_provider.load(Default::default())?.take_payload(),
provider,
provider.load(Default::default())?.take_payload()?,
provider.load(Default::default())?.take_payload()?,
provider.load(Default::default())?.take_payload()?,
|| provider.load(Default::default())?.take_payload(),
locale,
options,
)
}

fn try_new_unstable_internal<D>(
data_provider: &D,
provider: &D,
decompositions: DataPayload<CanonicalDecompositionDataV1Marker>,
tables: DataPayload<CanonicalDecompositionTablesV1Marker>,
jamo: DataPayload<CollationJamoV1Marker>,
Expand All @@ -150,20 +150,20 @@ impl Collator {
};

let metadata_payload: DataPayload<crate::provider::CollationMetadataV1Marker> =
data_provider.load(req)?.take_payload()?;
provider.load(req)?.take_payload()?;

let metadata = metadata_payload.get();

let tailoring: Option<DataPayload<crate::provider::CollationDataV1Marker>> =
if metadata.tailored() {
Some(data_provider.load(req)?.take_payload()?)
Some(provider.load(req)?.take_payload()?)
} else {
None
};

let reordering: Option<DataPayload<crate::provider::CollationReorderingV1Marker>> =
if metadata.reordering() {
Some(data_provider.load(req)?.take_payload()?)
Some(provider.load(req)?.take_payload()?)
} else {
None
};
Expand All @@ -175,10 +175,10 @@ impl Collator {
}

let root: DataPayload<CollationDataV1Marker> =
data_provider.load(Default::default())?.take_payload()?;
provider.load(Default::default())?.take_payload()?;

let tailored_diacritics = metadata.tailored_diacritics();
let diacritics: DataPayload<CollationDiacriticsV1Marker> = data_provider
let diacritics: DataPayload<CollationDiacriticsV1Marker> = provider
.load(if tailored_diacritics {
req
} else {
Expand Down
8 changes: 4 additions & 4 deletions components/datetime/src/any/date.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ impl DateFormatter {
/// This method will pick the calendar off of the locale; and if unspecified or unknown will fall back to the default
/// calendar for the locale. See [`AnyCalendarKind`] for a list of supported calendars.
///
/// ✨ *Enabled with the `compiled_data` Cargo feature.*
///
/// [📚 Help choosing a constructor](icu_provider::constructors)
///
/// # Examples
///
/// ```
Expand Down Expand Up @@ -96,10 +100,6 @@ impl DateFormatter {
/// "Sep 1, 2020"
/// );
/// ```
///
/// ✨ *Enabled with the `compiled_data` Cargo feature.*
///
/// [📚 Help choosing a constructor](icu_provider::constructors)
#[inline(never)]
#[cfg(feature = "compiled_data")]
pub fn try_new_with_length(
Expand Down
8 changes: 8 additions & 0 deletions components/datetime/src/any/datetime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,10 @@ impl DateTimeFormatter {
/// This method will pick the calendar off of the locale; and if unspecified or unknown will fall back to the default
/// calendar for the locale. See [`AnyCalendarKind`] for a list of supported calendars.
///
/// ✨ *Enabled with the `compiled_data` Cargo feature.*
///
/// [📚 Help choosing a constructor](icu_provider::constructors)
///
/// # Examples
///
/// ```
Expand Down Expand Up @@ -268,6 +272,10 @@ impl DateTimeFormatter {

/// Constructor that supports experimental options with compiled data.
///
/// ✨ *Enabled with the `compiled_data` Cargo feature.*
///
/// [📚 Help choosing a constructor](icu_provider::constructors)
///
/// <div class="stab unstable">
/// 🚧 This code is experimental; it may change at any time, in breaking or non-breaking ways,
/// including in SemVer minor releases. It can be enabled with the "experimental" Cargo feature
Expand Down
16 changes: 8 additions & 8 deletions components/datetime/src/any/zoned_datetime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,10 @@ impl ZonedDateTimeFormatter {
/// This method will pick the calendar off of the locale; and if unspecified or unknown will fall back to the default
/// calendar for the locale. See [`AnyCalendarKind`] for a list of supported calendars.
///
/// ✨ *Enabled with the `compiled_data` Cargo feature.*
///
/// [📚 Help choosing a constructor](icu_provider::constructors)
///
/// # Examples
///
/// ```
Expand Down Expand Up @@ -163,10 +167,6 @@ impl ZonedDateTimeFormatter {
/// "April 2021, 16:12 GMT-07:00"
/// );
/// ```
///
/// ✨ *Enabled with the `compiled_data` Cargo feature.*
///
/// [📚 Help choosing a constructor](icu_provider::constructors)
#[cfg(feature = "experimental")]
#[cfg(feature = "compiled_data")]
pub fn try_new_experimental(
Expand Down Expand Up @@ -276,6 +276,10 @@ impl ZonedDateTimeFormatter {
/// This method will pick the calendar off of the locale; and if unspecified or unknown will fall back to the default
/// calendar for the locale. See [`AnyCalendarKind`] for a list of supported calendars.
///
/// ✨ *Enabled with the `compiled_data` Cargo feature.*
///
/// [📚 Help choosing a constructor](icu_provider::constructors)
///
/// # Examples
///
/// ```
Expand Down Expand Up @@ -311,10 +315,6 @@ impl ZonedDateTimeFormatter {
/// "Apr 8, 2021, 4:12:37 PM GMT-07:00"
/// );
/// ```
///
/// ✨ *Enabled with the `compiled_data` Cargo feature.*
///
/// [📚 Help choosing a constructor](icu_provider::constructors)
#[cfg(feature = "compiled_data")]
pub fn try_new(
locale: &DataLocale,
Expand Down
Loading