File tree 2 files changed +8
-9
lines changed 2 files changed +8
-9
lines changed Original file line number Diff line number Diff line change @@ -433,9 +433,11 @@ def try_mutate_str():
433
433
f'{ 5.0 :04d} '
434
434
435
435
# Test % formatting
436
+ assert f'{ 10 :%} ' == '1000.000000%'
436
437
assert f'{ 10.0 :%} ' == '1000.000000%'
437
438
assert f'{ 10.0 :.2%} ' == '1000.00%'
438
439
assert f'{ 10.0 :.8%} ' == '1000.00000000%'
440
+ assert f'{ - 10 :%} ' == '-1000.000000%'
439
441
assert f'{ - 10.0 :%} ' == '-1000.000000%'
440
442
assert f'{ - 10.0 :.2%} ' == '-1000.00%'
441
443
assert f'{ - 10.0 :.8%} ' == '-1000.00000000%'
Original file line number Diff line number Diff line change @@ -447,15 +447,12 @@ impl FormatSpec {
447
447
Some ( FormatType :: ExponentLower ) => {
448
448
Err ( "Unknown format code 'e' for object of type 'int'" )
449
449
}
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
+ } ,
459
456
None => Ok ( magnitude. to_str_radix ( 10 ) ) ,
460
457
} ;
461
458
if raw_magnitude_string_result. is_err ( ) {
You can’t perform that action at this time.
0 commit comments