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

Baked data fixes in properties #3614

Merged
merged 7 commits into from
Jul 3, 2023
Merged
Show file tree
Hide file tree
Changes from 6 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
1 change: 0 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion components/properties/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ icu_locid_transform = { version = "1.2.0", path = "../../components/locid_transf

[dev-dependencies]
icu = { path = "../icu", default-features = false }
icu_testdata = { path = "../../provider/testdata", default-features = false, features = ["icu_properties", "icu_locid_transform"] }

[features]
std = ["icu_collections/std", "icu_provider/std"]
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions components/properties/src/bidi_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,15 @@ impl<'a> BidiAuxiliaryPropertiesBorrowed<'a> {
}
}

impl BidiAuxiliaryPropertiesBorrowed<'static> {
/// Cheaply converts a `BidiAuxiliaryPropertiesBorrowed<'static>` into a `BidiAuxiliaryProperties`.
pub fn static_to_owned(self) -> BidiAuxiliaryProperties {
BidiAuxiliaryProperties {
data: DataPayload::from_static_ref(self.data),
}
}
}

/// Returns a [`BidiAuxiliaryPropertiesV1`] struct that represents the data for certain
/// Bidi properties.
///
Expand Down
2 changes: 1 addition & 1 deletion components/properties/src/exemplar_chars.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ macro_rules! make_exemplar_chars_unicode_set_property {
#[cfg(feature = "compiled_data")]
$vis2 fn $constname(
locale: &DataLocale,
) -> Result<UnicodeSetData, DataError> {
) -> Result<UnicodeSetData, PropertiesError> {
Ok(UnicodeSetData::from_data(
DataProvider::<$keyed_data_marker>::load(
&crate::provider::Baked,
Expand Down
13 changes: 10 additions & 3 deletions components/properties/src/maps.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,7 @@ impl<T: TrieValue> CodePointMapData<T> {
/// ```
/// use icu::properties::{maps, GeneralCategory};
///
/// let data =
/// maps::load_general_category(&icu_testdata::unstable())
/// .expect("The data should be valid");
/// let data = maps::general_category().static_to_owned();
///
/// let gc = data.try_into_converted::<u8>().unwrap();
/// let gc = gc.as_borrowed();
Expand Down Expand Up @@ -262,6 +260,15 @@ impl<'a, T: TrieValue> CodePointMapDataBorrowed<'a, T> {
}
}

impl<T: TrieValue> CodePointMapDataBorrowed<'static, T> {
/// Cheaply converts a `CodePointMapDataBorrowed<'static>` into a `CodePointMapData`.
pub fn static_to_owned(self) -> CodePointMapData<T> {
CodePointMapData {
data: DataPayload::from_static_ref(self.map),
}
}
}

impl<'a> CodePointMapDataBorrowed<'a, crate::GeneralCategory> {
/// Yields an [`Iterator`] returning ranges of consecutive code points that
/// have a `General_Category` value belonging to the specified [`GeneralCategoryGroup`]
Expand Down
Loading