File tree Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -242,8 +242,14 @@ impl WidthHeuristics {
242
242
243
243
// scale the default WidthHeuristics according to max_width
244
244
pub fn scaled ( max_width : usize ) -> WidthHeuristics {
245
- let mut max_width_ratio: f32 = max_width as f32 / 100.0 ; // 100 is the default width -> default ratio is 1
246
- max_width_ratio = ( max_width_ratio * 10.0 ) . round ( ) / 10.0 ; // round to the closest 0.1
245
+ const DEFAULT_MAX_WIDTH : usize = 100 ;
246
+ let max_width_ratio = if max_width > DEFAULT_MAX_WIDTH {
247
+ let ratio = max_width as f32 / DEFAULT_MAX_WIDTH as f32 ;
248
+ // round to the closest 0.1
249
+ ( ratio * 10.0 ) . round ( ) / 10.0
250
+ } else {
251
+ 1.0
252
+ } ;
247
253
WidthHeuristics {
248
254
fn_call_width : ( 60.0 * max_width_ratio) . round ( ) as usize ,
249
255
struct_lit_width : ( 18.0 * max_width_ratio) . round ( ) as usize ,
You can’t perform that action at this time.
0 commit comments