@@ -124,20 +124,24 @@ fn test_currency() {
124
124
125
125
let mut options = CollatorOptions :: default ( ) ;
126
126
options. strength = Some ( Strength :: Quaternary ) ;
127
-
128
127
let collator = Collator :: try_new ( Default :: default ( ) , options) . unwrap ( ) ;
129
- // Iterating as chars and re-encoding due to
130
- // https://github.com/rust-lang/rust/issues/83871 being nightly-only. :-(
131
- let mut lower_buf = [ 0u8 ; 4 ] ;
132
- let mut higher_buf = [ 0u8 ; 4 ] ;
133
- let mut chars = currencies. chars ( ) ;
134
- while let Some ( lower) = chars. next ( ) {
135
- let tail = chars. clone ( ) ;
136
- for higher in tail {
137
- let lower_str = lower. encode_utf8 ( & mut lower_buf) ;
138
- let higher_str = higher. encode_utf8 ( & mut higher_buf) ;
139
- assert_eq ! ( collator. compare( lower_str, higher_str) , Ordering :: Less ) ;
128
+ let mut chars = currencies. char_indices ( ) ;
129
+ let mut lower_start = chars. offset ( ) ;
130
+ while let Some ( _) = chars. next ( ) {
131
+ let lower_end = chars. offset ( ) ;
132
+ let higher_start = lower_end;
133
+ let mut tail = chars. clone ( ) ;
134
+ while let Some ( _) = tail. next ( ) {
135
+ let higher_end = tail. offset ( ) ;
136
+ assert_eq ! (
137
+ collator. compare(
138
+ & currencies[ lower_start..lower_end] ,
139
+ & currencies[ higher_start..higher_end]
140
+ ) ,
141
+ Ordering :: Less
142
+ ) ;
140
143
}
144
+ lower_start = higher_start;
141
145
}
142
146
}
143
147
0 commit comments