File tree Expand file tree Collapse file tree 1 file changed +8
-8
lines changed Expand file tree Collapse file tree 1 file changed +8
-8
lines changed Original file line number Diff line number Diff line change @@ -36,20 +36,20 @@ impl f::Size {
36
36
} ;
37
37
38
38
let ( prefix, n) = match result {
39
- NumberPrefix :: Standalone ( b) => return TextCell :: paint ( colours. size ( None ) , b . to_string ( ) ) ,
39
+ NumberPrefix :: Standalone ( b) => return TextCell :: paint ( colours. size ( None ) , numerics . format_int ( b ) ) ,
40
40
NumberPrefix :: Prefixed ( p, n) => ( p, n) ,
41
41
} ;
42
42
43
43
let symbol = prefix. symbol ( ) ;
44
- let decimal_to_diplay = if n < 10_f64 { 1 } else { 0 } ;
45
- let number = numerics. format_float ( n, decimal_to_diplay) ;
44
+ let number = if n < 10_f64 {
45
+ numerics. format_float ( n, 1 )
46
+ } else {
47
+ numerics. format_int ( n. round ( ) as isize )
48
+ } ;
46
49
47
- // The numbers and symbols are guaranteed to be written in ASCII, so
48
- // we can skip the display width calculation.
49
- let width = DisplayWidth :: from ( number. len ( ) + symbol. len ( ) ) ;
50
-
51
50
TextCell {
52
- width,
51
+ // symbol is guaranteed to be ASCII since unit prefixes are hardcoded.
52
+ width : DisplayWidth :: from ( & * number) + symbol. len ( ) ,
53
53
contents : vec ! [
54
54
colours. size( Some ( prefix) ) . paint( number) ,
55
55
colours. unit( Some ( prefix) ) . paint( symbol) ,
You can’t perform that action at this time.
0 commit comments