@@ -375,14 +375,16 @@ impl str {
375
375
// Safety: We have written only valid ASCII to our vec
376
376
let mut s = unsafe { String :: from_utf8_unchecked ( out) } ;
377
377
378
- for ( i, c) in rest[ .. ] . char_indices ( ) {
378
+ for ( i, c) in rest. char_indices ( ) {
379
379
if c == 'Σ' {
380
380
// Σ maps to σ, except at the end of a word where it maps to ς.
381
381
// This is the only conditional (contextual) but language-independent mapping
382
382
// in `SpecialCasing.txt`,
383
383
// so hard-code it rather than have a generic "condition" mechanism.
384
384
// See https://github.com/rust-lang/rust/issues/26035
385
- map_uppercase_sigma ( rest, i, & mut s)
385
+ let out_len = self . len ( ) - rest. len ( ) ;
386
+ let sigma_lowercase = map_uppercase_sigma ( & self , i + out_len) ;
387
+ s. push ( sigma_lowercase) ;
386
388
} else {
387
389
match conversions:: to_lower ( c) {
388
390
[ a, '\0' , _] => s. push ( a) ,
@@ -400,13 +402,13 @@ impl str {
400
402
}
401
403
return s;
402
404
403
- fn map_uppercase_sigma ( from : & str , i : usize , to : & mut String ) {
405
+ fn map_uppercase_sigma ( from : & str , i : usize ) -> char {
404
406
// See https://www.unicode.org/versions/Unicode7.0.0/ch03.pdf#G33992
405
407
// for the definition of `Final_Sigma`.
406
408
debug_assert ! ( 'Σ' . len_utf8( ) == 2 ) ;
407
409
let is_word_final = case_ignorable_then_cased ( from[ ..i] . chars ( ) . rev ( ) )
408
410
&& !case_ignorable_then_cased ( from[ i + 2 ..] . chars ( ) ) ;
409
- to . push_str ( if is_word_final { "ς" } else { "σ" } ) ;
411
+ if is_word_final { 'ς' } else { 'σ' }
410
412
}
411
413
412
414
fn case_ignorable_then_cased < I : Iterator < Item = char > > ( iter : I ) -> bool {
0 commit comments