@@ -438,7 +438,7 @@ impl FormatSpec {
438
438
}
439
439
} ;
440
440
441
- self . format_sign_and_align ( & magnitude_string, sign_str, FormatAlign :: Right )
441
+ self . format_sign_and_align ( ( & magnitude_string, true ) , sign_str, FormatAlign :: Right )
442
442
}
443
443
444
444
#[ inline]
@@ -510,13 +510,13 @@ impl FormatSpec {
510
510
} ,
511
511
} ;
512
512
513
- self . format_sign_and_align ( & magnitude_string, sign_str, FormatAlign :: Right )
513
+ self . format_sign_and_align ( ( & magnitude_string, true ) , sign_str, FormatAlign :: Right )
514
514
}
515
515
516
- pub ( crate ) fn format_string ( & self , s : & str ) -> Result < String , & ' static str > {
516
+ pub ( crate ) fn format_string ( & self , s : & str , ascii_only : bool ) -> Result < String , & ' static str > {
517
517
match self . format_type {
518
518
Some ( FormatType :: String ) | None => self
519
- . format_sign_and_align ( s , "" , FormatAlign :: Left )
519
+ . format_sign_and_align ( ( s , ascii_only ) , "" , FormatAlign :: Left )
520
520
. map ( |mut value| {
521
521
if let Some ( precision) = self . precision {
522
522
value. truncate ( precision) ;
@@ -529,13 +529,14 @@ impl FormatSpec {
529
529
530
530
fn format_sign_and_align (
531
531
& self ,
532
- magnitude_string : & str ,
532
+ ( magnitude_string, magnitude_ascii_hint ) : ( & str , bool ) ,
533
533
sign_str : & str ,
534
534
default_align : FormatAlign ,
535
535
) -> Result < String , & ' static str > {
536
536
let align = self . align . unwrap_or ( default_align) ;
537
537
538
- let num_chars = if magnitude_string. is_ascii ( ) {
538
+ let num_chars = if magnitude_ascii_hint {
539
+ debug_assert ! ( magnitude_string. is_ascii( ) ) ;
539
540
magnitude_string. len ( )
540
541
} else {
541
542
magnitude_string. chars ( ) . count ( )
0 commit comments