@@ -126,18 +126,23 @@ fn test_currency() {
126
126
options. strength = Some ( Strength :: Quaternary ) ;
127
127
128
128
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 ) ;
129
+ let mut chars = currencies. char_indices ( ) ;
130
+ let mut lower_start = chars. offset ( ) ;
131
+ while let Some ( _) = chars. next ( ) {
132
+ let lower_end = chars. offset ( ) ;
133
+ let higher_start = lower_end;
134
+ let mut tail = chars. clone ( ) ;
135
+ while let Some ( _) = tail. next ( ) {
136
+ let higher_end = tail. offset ( ) ;
137
+ assert_eq ! (
138
+ collator. compare(
139
+ & currencies[ lower_start..lower_end] ,
140
+ & currencies[ higher_start..higher_end]
141
+ ) ,
142
+ Ordering :: Less
143
+ ) ;
140
144
}
145
+ lower_start = higher_start;
141
146
}
142
147
}
143
148
0 commit comments