File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -433,9 +433,11 @@ def try_mutate_str():
433433 f'{ 5.0 :04d} '
434434
435435# Test % formatting
436+ assert f'{ 10 :%} ' == '1000.000000%'
436437assert f'{ 10.0 :%} ' == '1000.000000%'
437438assert f'{ 10.0 :.2%} ' == '1000.00%'
438439assert f'{ 10.0 :.8%} ' == '1000.00000000%'
440+ assert f'{ - 10 :%} ' == '-1000.000000%'
439441assert f'{ - 10.0 :%} ' == '-1000.000000%'
440442assert f'{ - 10.0 :.2%} ' == '-1000.00%'
441443assert f'{ - 10.0 :.8%} ' == '-1000.00000000%'
Original file line number Diff line number Diff line change @@ -447,15 +447,12 @@ impl FormatSpec {
447447 Some ( FormatType :: ExponentLower ) => {
448448 Err ( "Unknown format code 'e' for object of type 'int'" )
449449 }
450- Some ( FormatType :: FixedPointUpper ) | Some ( FormatType :: FixedPointLower ) => {
451- match num. to_f64 ( ) {
452- Some ( float) => return self . format_float ( float) ,
453- _ => Err ( "Unable to convert int to float" ) ,
454- }
455- }
456- Some ( FormatType :: Percentage ) => {
457- Err ( "Format code '%' for object of type 'int' not implemented yet" )
458- }
450+ Some ( FormatType :: FixedPointUpper )
451+ | Some ( FormatType :: FixedPointLower )
452+ | Some ( FormatType :: Percentage ) => match num. to_f64 ( ) {
453+ Some ( float) => return self . format_float ( float) ,
454+ _ => Err ( "Unable to convert int to float" ) ,
455+ } ,
459456 None => Ok ( magnitude. to_str_radix ( 10 ) ) ,
460457 } ;
461458 if raw_magnitude_string_result. is_err ( ) {
You can’t perform that action at this time.
0 commit comments