@@ -21,7 +21,7 @@ use crate::elements::FALLBACK_CE32;
2121use crate :: elements:: NON_ROUND_TRIP_MARKER ;
2222use crate :: elements:: {
2323 char_from_u32, CollationElement , CollationElements , NonPrimary , FFFD_CE32 ,
24- HANGUL_SYLLABLE_MARKER , HIGH_ZEROS_MASK , JAMO_COUNT , LOW_ZEROS_MASK , NO_CE , NO_CE_PRIMARY ,
24+ HANGUL_SYLLABLE_MARKER , HIGH_ZEROS_MASK , LOW_ZEROS_MASK , NO_CE , NO_CE_PRIMARY ,
2525 NO_CE_QUATERNARY , NO_CE_SECONDARY , NO_CE_TERTIARY , OPTIMIZED_DIACRITICS_MAX_COUNT ,
2626 QUATERNARY_MASK ,
2727} ;
@@ -43,7 +43,7 @@ use crate::provider::CollationSpecialPrimariesV1;
4343use crate :: provider:: CollationSpecialPrimariesValidated ;
4444use crate :: provider:: CollationTailoringV1 ;
4545use core:: cmp:: Ordering ;
46- use core:: convert:: { Infallible , TryFrom } ;
46+ use core:: convert:: Infallible ;
4747use icu_normalizer:: provider:: DecompositionData ;
4848use icu_normalizer:: provider:: DecompositionTables ;
4949use icu_normalizer:: provider:: NormalizerNfdDataV1 ;
@@ -55,7 +55,6 @@ use icu_provider::prelude::*;
5555use smallvec:: SmallVec ;
5656use utf16_iter:: Utf16CharsEx ;
5757use utf8_iter:: Utf8CharsEx ;
58- use zerovec:: ule:: AsULE ;
5958
6059// Special sort key bytes for all levels.
6160const LEVEL_SEPARATOR_BYTE : u8 = 1 ;
@@ -649,16 +648,6 @@ impl Collator {
649648 let locale_dependent =
650649 LocaleSpecificDataHolder :: try_new_unstable_internal ( provider, prefs, options) ?;
651650
652- // TODO: redesign Korean search collation handling
653- if jamo. get ( ) . ce32s . len ( ) != JAMO_COUNT {
654- return Err ( DataError :: custom ( "invalid" ) . with_marker ( CollationJamoV1 :: INFO ) ) ;
655- }
656-
657- // `variant_count` isn't stable yet:
658- // https://github.com/rust-lang/rust/issues/73662
659- if special_primaries. get ( ) . last_primaries . len ( ) <= ( MaxVariable :: Currency as usize ) {
660- return Err ( DataError :: custom ( "invalid" ) . with_marker ( CollationSpecialPrimariesV1 :: INFO ) ) ;
661- }
662651 let special_primaries = special_primaries. map_project ( |csp, _| {
663652 let compressible_bytes = ( csp. last_primaries . len ( )
664653 == MaxVariable :: Currency as usize + 16 )
@@ -758,25 +747,6 @@ impl CollatorBorrowed<'static> {
758747 let locale_dependent =
759748 LocaleSpecificDataHolder :: try_new_unstable_internal ( provider, prefs, options) ?;
760749
761- // TODO: redesign Korean search collation handling
762- const _: ( ) = assert ! (
763- crate :: provider:: Baked :: SINGLETON_COLLATION_JAMO_V1
764- . ce32s
765- . as_slice( )
766- . len( )
767- == JAMO_COUNT
768- ) ;
769-
770- // `variant_count` isn't stable yet:
771- // https://github.com/rust-lang/rust/issues/73662
772- const _: ( ) = assert ! (
773- crate :: provider:: Baked :: SINGLETON_COLLATION_SPECIAL_PRIMARIES_V1
774- . last_primaries
775- . as_slice( )
776- . len( )
777- > ( MaxVariable :: Currency as usize )
778- ) ;
779-
780750 let special_primaries = const {
781751 & CollationSpecialPrimariesValidated {
782752 last_primaries : zerovec:: ZeroSlice :: from_ule_slice (
@@ -791,7 +761,7 @@ impl CollatorBorrowed<'static> {
791761 numeric_primary : crate :: provider:: Baked :: SINGLETON_COLLATION_SPECIAL_PRIMARIES_V1
792762 . numeric_primary ,
793763 compressible_bytes : {
794- const C : & [ <u16 as AsULE >:: ULE ] =
764+ const C : & [ <u16 as zerovec :: ule :: AsULE >:: ULE ] =
795765 crate :: provider:: Baked :: SINGLETON_COLLATION_SPECIAL_PRIMARIES_V1
796766 . last_primaries
797767 . as_slice ( )
@@ -874,27 +844,25 @@ impl CollatorBorrowed<'static> {
874844 }
875845}
876846
877- macro_rules! collation_elements {
878- ( $self: expr, $chars: expr, $tailoring: expr, $numeric_primary: expr) => { {
879- let jamo = <& [ <u32 as AsULE >:: ULE ; JAMO_COUNT ] >:: try_from( $self. jamo. ce32s. as_ule_slice( ) ) ;
880-
881- let jamo = jamo. unwrap( ) ;
882-
847+ impl < ' a > CollatorBorrowed < ' a > {
848+ fn collation_elements < C : Iterator < Item = char > > (
849+ & self ,
850+ chars : C ,
851+ tailoring : & ' a CollationData < ' a > ,
852+ numeric_primary : Option < u8 > ,
853+ ) -> CollationElements < ' a , C > {
883854 CollationElements :: new (
884- $ chars,
885- $ self. root,
886- $ tailoring,
887- jamo,
888- & $ self. diacritics. secondaries,
889- $ self. decompositions,
890- $ self. tables,
891- $ numeric_primary,
892- $ self. lithuanian_dot_above,
855+ chars,
856+ self . root ,
857+ tailoring,
858+ self . jamo . as_array ( ) ,
859+ & self . diacritics . secondaries ,
860+ self . decompositions ,
861+ self . tables ,
862+ numeric_primary,
863+ self . lithuanian_dot_above ,
893864 )
894- } } ;
895- }
896-
897- impl CollatorBorrowed < ' _ > {
865+ }
898866 /// The resolved options showing how the default options, the requested options,
899867 /// and the options from locale data were combined.
900868 pub fn resolved_options ( & self ) -> ResolvedCollatorOptions {
@@ -971,7 +939,7 @@ impl CollatorBorrowed<'_> {
971939 ) ;
972940
973941 #[ inline( always) ]
974- fn tailoring_or_root ( & self ) -> & CollationData < ' _ > {
942+ fn tailoring_or_root ( & self ) -> & ' a CollationData < ' a > {
975943 if let Some ( tailoring) = & self . tailoring {
976944 tailoring
977945 } else {
@@ -1052,8 +1020,8 @@ impl CollatorBorrowed<'_> {
10521020
10531021 let tailoring = self . tailoring_or_root ( ) ;
10541022 let numeric_primary = self . numeric_primary ( ) ;
1055- let mut left = collation_elements ! ( self , left_chars, tailoring, numeric_primary) ;
1056- let mut right = collation_elements ! ( self , right_chars, tailoring, numeric_primary) ;
1023+ let mut left = self . collation_elements ( left_chars, tailoring, numeric_primary) ;
1024+ let mut right = self . collation_elements ( right_chars, tailoring, numeric_primary) ;
10571025
10581026 // Start identical prefix
10591027
@@ -1922,7 +1890,7 @@ impl CollatorBorrowed<'_> {
19221890 let levels = self . sort_key_levels ( ) ;
19231891
19241892 let mut iter =
1925- collation_elements ! ( self , iter, self . tailoring_or_root( ) , self . numeric_primary( ) ) ;
1893+ self . collation_elements ( iter, self . tailoring_or_root ( ) , self . numeric_primary ( ) ) ;
19261894 iter. init ( ) ;
19271895 let variable_top = self . variable_top ( ) ;
19281896
0 commit comments