Skip to content

Commit 6effe74

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 6effe74

File tree

1 file changed

+16
-12
lines changed

1 file changed

+16
-12
lines changed

components/collator/tests/tests.rs

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -124,20 +124,24 @@ fn test_currency() {
124124

125125
let mut options = CollatorOptions::default();
126126
options.strength = Some(Strength::Quaternary);
127-
128127
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+
);
140143
}
144+
lower_start = higher_start;
141145
}
142146
}
143147

0 commit comments

Comments
 (0)