Skip to content

Commit

Permalink
Refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
sffc committed Dec 19, 2023
1 parent ab39def commit 11a1ed1
Showing 1 changed file with 15 additions and 14 deletions.
29 changes: 15 additions & 14 deletions provider/datagen/src/provider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,19 @@ impl DatagenProvider {
) -> Result<impl IntoIterator<Item = icu_locid::LanguageIdentifier>, DataError> {
self.cldr()?.locales(levels)
}

pub(crate) fn supported_locales_vec<M>(&self) -> Result<&Vec<DataLocale>, DataError>
where
M: KeyedDataMarker,
Self: IterableDataProviderInternal<M>,
{
#[allow(deprecated)] // SourceData
self.source
.supported_locales_cache_vec
.insert_with(M::KEY, || Box::from(self.supported_locales_impl()))
.as_ref()
.map_err(|e| *e)
}
}

/// Specifies the trie type to use.
Expand Down Expand Up @@ -500,22 +513,10 @@ where
DatagenProvider: IterableDataProviderInternal<M>,
{
fn supported_locales(&self) -> Result<Vec<DataLocale>, DataError> {
#[allow(deprecated)] // SourceData
self.source
.supported_locales_cache_vec
.insert_with(M::KEY, || Box::from(self.supported_locales_impl()))
.as_ref()
.cloned()
.map_err(|e| *e)
self.supported_locales_vec().cloned()
}

fn supports_locale(&self, locale: &DataLocale) -> Result<bool, DataError> {
#[allow(deprecated)] // SourceData
self.source
.supported_locales_cache_vec
.insert_with(M::KEY, || Box::from(self.supported_locales_impl()))
.as_ref()
.map_err(|e| *e)
.map(|v| v.contains(locale))
self.supported_locales_vec().map(|v| v.contains(locale))
}
}

0 comments on commit 11a1ed1

Please sign in to comment.