Skip to content

Commit 7ddd087

Browse files
committed
Update to use new API
Feature char_indices_offset is stabilized in Rust 1.82 (current rust-version of icu). So changed to use it.
1 parent a343251 commit 7ddd087

File tree

1 file changed

+16
-11
lines changed

1 file changed

+16
-11
lines changed

components/collator/tests/tests.rs

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -126,18 +126,23 @@ fn test_currency() {
126126
options.strength = Some(Strength::Quaternary);
127127

128128
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+
);
140144
}
145+
lower_start = higher_start;
141146
}
142147
}
143148

0 commit comments

Comments
 (0)