-
Notifications
You must be signed in to change notification settings - Fork 267
infallible new_root #7657
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
infallible new_root #7657
Changes from all commits
4244f45
352edd9
5f25a73
7b9c8fa
ba15249
a540f48
2a2356c
9c3a1e9
29ca888
95f4fae
3931c22
3d23b13
8d1dd02
e6c7684
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -844,6 +844,87 @@ impl CollatorBorrowed<'static> { | |
| }) | ||
| } | ||
|
|
||
| /// This creates a root collator using baked data only. | ||
| /// | ||
| /// ✨ *Enabled with the `unstable` Cargo feature.* | ||
| #[cfg(feature = "compiled_data")] | ||
| #[cfg(feature = "unstable")] | ||
| pub const fn new_root() -> Self { | ||
| const _: () = assert!( | ||
| crate::provider::Baked::SINGLETON_COLLATION_JAMO_V1 | ||
| .ce32s | ||
| .as_slice() | ||
| .len() | ||
| == JAMO_COUNT | ||
| ); | ||
| const _: () = assert!( | ||
| crate::provider::Baked::SINGLETON_COLLATION_SPECIAL_PRIMARIES_V1 | ||
| .last_primaries | ||
| .as_slice() | ||
| .len() | ||
| > (MaxVariable::Currency as usize) | ||
| ); | ||
|
|
||
| Self { | ||
| special_primaries: const { | ||
| &CollationSpecialPrimariesValidated { | ||
| last_primaries: zerovec::ZeroSlice::from_ule_slice( | ||
| crate::provider::Baked::SINGLETON_COLLATION_SPECIAL_PRIMARIES_V1 | ||
| .last_primaries | ||
| .as_slice() | ||
| .as_ule_slice() | ||
| .split_at(MaxVariable::Currency as usize) | ||
| .0, | ||
| ) | ||
| .as_zerovec(), | ||
| numeric_primary: | ||
| crate::provider::Baked::SINGLETON_COLLATION_SPECIAL_PRIMARIES_V1 | ||
| .numeric_primary, | ||
| compressible_bytes: { | ||
| const C: &[<u16 as AsULE>::ULE] = | ||
| crate::provider::Baked::SINGLETON_COLLATION_SPECIAL_PRIMARIES_V1 | ||
| .last_primaries | ||
| .as_slice() | ||
| .as_ule_slice(); | ||
| if C.len() == MaxVariable::Currency as usize + 16 { | ||
| let i = MaxVariable::Currency as usize; | ||
| #[allow(clippy::indexing_slicing)] | ||
| &[ | ||
| C[i], | ||
| C[i + 1], | ||
| C[i + 2], | ||
| C[i + 3], | ||
| C[i + 4], | ||
|
Comment on lines
+892
to
+897
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Issue: This code is heavily duplicated from
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. #7872 refactors this |
||
| C[i + 5], | ||
| C[i + 6], | ||
| C[i + 7], | ||
| C[i + 8], | ||
| C[i + 9], | ||
| C[i + 10], | ||
| C[i + 11], | ||
| C[i + 12], | ||
| C[i + 13], | ||
| C[i + 14], | ||
| C[i + 15], | ||
| ] | ||
| } else { | ||
| CollationSpecialPrimariesValidated::HARDCODED_COMPRESSIBLE_BYTES_FALLBACK | ||
| } | ||
| }, | ||
| } | ||
| }, | ||
| root: crate::provider::Baked::SINGLETON_COLLATION_ROOT_V1, | ||
| tailoring: None, | ||
| jamo: crate::provider::Baked::SINGLETON_COLLATION_JAMO_V1, | ||
| options: CollatorOptionsBitField::default(), | ||
| diacritics: crate::provider::Baked::COLLATION_DIACRITICS_V1_UND, | ||
| reordering: None, | ||
| decompositions: icu_normalizer::provider::Baked::SINGLETON_NORMALIZER_NFD_DATA_V1, | ||
| tables: icu_normalizer::provider::Baked::SINGLETON_NORMALIZER_NFD_TABLES_V1, | ||
| lithuanian_dot_above: false, | ||
| } | ||
| } | ||
|
|
||
| /// Cheaply converts a [`CollatorBorrowed<'static>`] into a [`Collator`]. | ||
| /// | ||
| /// Note: Due to branching and indirection, using [`Collator`] might inhibit some | ||
|
|
||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
issue: this should take
CollatorOptionsThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CollatorOptionsBitField::from(CollatorOptions)is not const fn, so acceptingCollatorOptionsinnew_root()would require either making the conversion const or dropping the const fn. how should i proceed?