Skip to content

Commit

Permalink
Put MaybeEncodeAsVarULE behind the "export" feature (#6221)
Browse files Browse the repository at this point in the history
Part of #5230
  • Loading branch information
sffc authored Mar 4, 2025
1 parent 2aebf55 commit c4e5f41
Show file tree
Hide file tree
Showing 11 changed files with 16 additions and 10 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
- Data model and providers
- General
- ...
- ...
- `icu_provider`
- Put `MaybeEncodeAsVarULE` behind the `"export"` feature (unicode-org#6221)
- Utils
- General
- ...
Expand Down
2 changes: 1 addition & 1 deletion components/calendar/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ default = ["compiled_data", "ixdtf"]
ixdtf = ["dep:ixdtf"]
logging = ["calendrical_calculations/logging"]
serde = ["dep:serde", "zerovec/serde", "tinystr/serde", "icu_provider/serde"]
datagen = ["serde", "dep:databake", "zerovec/databake", "tinystr/databake", "alloc"]
datagen = ["serde", "dep:databake", "zerovec/databake", "tinystr/databake", "alloc", "icu_provider/export"]
compiled_data = ["dep:icu_calendar_data"]
alloc = []

Expand Down
2 changes: 1 addition & 1 deletion components/casemap/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ criterion = { workspace = true }
[features]
default = ["compiled_data"]
serde = ["dep:serde", "zerovec/serde", "icu_collections/serde", "icu_provider/serde", "icu_properties/serde", "potential_utf/serde"]
datagen = ["serde", "dep:databake", "zerovec/databake", "icu_collections/databake"]
datagen = ["serde", "dep:databake", "zerovec/databake", "icu_collections/databake", "icu_provider/export"]
compiled_data = ["dep:icu_casemap_data", "icu_properties/compiled_data"]

[package.metadata.cargo-all-features]
Expand Down
2 changes: 1 addition & 1 deletion components/list/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ serde_json = { workspace = true }
default = ["compiled_data"]
serde = ["dep:serde", "icu_provider/serde", "icu_provider/alloc", "zerovec/serde"]
serde_human = ["serde", "regex-automata/dfa-build", "regex-automata/syntax", "alloc"]
datagen = ["serde", "dep:databake", "regex-automata/dfa-build", "regex-automata/syntax", "zerovec/databake", "alloc", "serde_human"]
datagen = ["serde", "dep:databake", "regex-automata/dfa-build", "regex-automata/syntax", "zerovec/databake", "alloc", "serde_human", "icu_provider/export"]
compiled_data = ["dep:icu_list_data"]
alloc = ["zerovec/alloc", "icu_provider/alloc", "serde?/alloc"]

Expand Down
2 changes: 1 addition & 1 deletion components/locale/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ bench = false # This option is required for Benchmark CI
[features]
default = ["compiled_data"]
serde = ["dep:serde", "icu_locale_core/serde", "tinystr/serde", "zerovec/serde", "icu_provider/serde", "potential_utf/serde", "icu_collections/serde"]
datagen = ["serde", "dep:databake", "zerovec/databake", "icu_locale_core/databake", "tinystr/databake", "icu_collections/databake"]
datagen = ["serde", "dep:databake", "zerovec/databake", "icu_locale_core/databake", "tinystr/databake", "icu_collections/databake", "icu_provider/export"]
compiled_data = ["dep:icu_locale_data"]

[[bench]]
Expand Down
2 changes: 1 addition & 1 deletion components/normalizer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ default = ["compiled_data", "utf8_iter", "utf16_iter"]
serde = ["dep:serde", "icu_collections/serde", "zerovec/serde", "icu_properties?/serde", "icu_provider/serde"]
# n.b. "icu_properties" + "icu_properties?/datagen" is equivalent to "icu_properties/datagen", however
# we specify this explicitly since "optional_dep/feature" is a footgun that leads to us often accidentally enabling features
datagen = ["serde", "dep:databake", "icu_properties", "icu_collections/databake", "zerovec/databake", "icu_properties?/datagen"]
datagen = ["serde", "dep:databake", "icu_properties", "icu_collections/databake", "zerovec/databake", "icu_properties?/datagen", "icu_provider/export"]
experimental = []
compiled_data = ["dep:icu_normalizer_data", "icu_properties?/compiled_data"]
icu_properties = ["dep:icu_properties"]
Expand Down
2 changes: 1 addition & 1 deletion components/plurals/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ criterion = { workspace = true }
[features]
default = ["compiled_data"]
serde = ["dep:serde", "zerovec/serde", "icu_locale_core/serde", "icu_provider/serde"]
datagen = ["serde", "zerovec/databake", "dep:databake"]
datagen = ["serde", "zerovec/databake", "dep:databake", "icu_provider/export"]
experimental = []
compiled_data = ["dep:icu_plurals_data"]

Expand Down
2 changes: 1 addition & 1 deletion components/properties/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ icu = { path = "../../components/icu", default-features = false }
[features]
default = ["compiled_data"]
serde = ["dep:serde", "icu_locale_core/serde", "potential_utf/serde", "zerovec/serde", "icu_collections/serde", "icu_provider/serde", "zerotrie/serde"]
datagen = ["serde", "dep:databake", "potential_utf/databake", "zerovec/databake", "icu_collections/databake", "icu_locale_core/databake", "zerotrie/databake"]
datagen = ["serde", "dep:databake", "potential_utf/databake", "zerovec/databake", "icu_collections/databake", "icu_locale_core/databake", "zerotrie/databake", "icu_provider/export"]
unicode_bidi = [ "dep:unicode-bidi" ]
compiled_data = ["dep:icu_properties_data"]
alloc = ["zerovec/alloc", "icu_collections/alloc"]
2 changes: 1 addition & 1 deletion components/time/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,6 @@ icu = { path = "../../components/icu", default-features = false }
default = ["compiled_data", "ixdtf"]
ixdtf = ["dep:ixdtf", "icu_calendar/ixdtf"]
serde = ["dep:serde", "zerovec/serde", "zerotrie/serde", "tinystr/serde", "icu_provider/serde"]
datagen = ["serde", "dep:databake", "zerovec/databake", "zerotrie/databake", "tinystr/databake"]
datagen = ["serde", "dep:databake", "zerovec/databake", "zerotrie/databake", "tinystr/databake", "icu_provider/export"]
compiled_data = ["dep:icu_time_data", "icu_calendar/compiled_data"]
alloc = ["tinystr/alloc", "zerotrie/alloc", "serde?/alloc"]
1 change: 1 addition & 0 deletions provider/core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ pub mod ule {
//! See [`MaybeAsVarULE`] for details.
pub use super::varule_traits::MaybeAsVarULE;
#[cfg(feature = "export")]
pub use super::varule_traits::MaybeEncodeAsVarULE;
}

Expand Down
6 changes: 5 additions & 1 deletion provider/core/src/varule_traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ pub trait MaybeAsVarULE {

/// Export-only trait associated with [`MaybeAsVarULE`]. See that trait
/// for additional details.
// #[cfg(feature = "export")] // TODO(#5230): Enable feature gating
///
/// ✨ *Enabled with the `export` Cargo feature.*
#[cfg(feature = "export")]
pub trait MaybeEncodeAsVarULE: MaybeAsVarULE {
/// Returns the [`MaybeAsVarULE::EncodedStruct`] that represents this data struct,
/// or `None` if the data struct does not support this representation.
Expand Down Expand Up @@ -96,6 +98,7 @@ where
}

#[cfg(feature = "alloc")]
#[cfg(feature = "export")]
impl<'a, K0, K1, V> MaybeEncodeAsVarULE for ZeroMap2d<'a, K0, K1, V>
where
K0: ZeroMapKV<'a>,
Expand All @@ -114,6 +117,7 @@ impl<T, const N: usize> MaybeAsVarULE for [T; N] {
type EncodedStruct = [()];
}

#[cfg(feature = "export")]
impl<T, const N: usize> MaybeEncodeAsVarULE for [T; N] {
fn maybe_encode_as_varule(&self) -> Option<&Self::EncodedStruct> {
None
Expand Down

0 comments on commit c4e5f41

Please sign in to comment.