@@ -436,38 +436,7 @@ pub fn rewrite_array<T: Rewrite + Spanned + ToExpr>(
436
436
}
437
437
}
438
438
439
- let has_long_item = items
440
- . iter ( )
441
- . any ( |li| li. item . as_ref ( ) . map ( |s| s. len ( ) > 10 ) . unwrap_or ( false ) ) ;
442
-
443
- let tactic = match context. config . indent_style ( ) {
444
- IndentStyle :: Block => {
445
- // FIXME wrong shape in one-line case
446
- match shape. width . checked_sub ( 2 * bracket_size) {
447
- Some ( width) => {
448
- let tactic = ListTactic :: LimitedHorizontalVertical (
449
- context. config . width_heuristics ( ) . array_width ,
450
- ) ;
451
- definitive_tactic ( & items, tactic, Separator :: Comma , width)
452
- }
453
- None => DefinitiveListTactic :: Vertical ,
454
- }
455
- }
456
- IndentStyle :: Visual => {
457
- if has_long_item || items. iter ( ) . any ( ListItem :: is_multiline) {
458
- definitive_tactic (
459
- & items,
460
- ListTactic :: LimitedHorizontalVertical (
461
- context. config . width_heuristics ( ) . array_width ,
462
- ) ,
463
- Separator :: Comma ,
464
- nested_shape. width ,
465
- )
466
- } else {
467
- DefinitiveListTactic :: Mixed
468
- }
469
- }
470
- } ;
439
+ let tactic = array_tactic ( context, shape, nested_shape, exprs, & items, bracket_size) ;
471
440
let ends_with_newline = tactic. ends_with_newline ( context. config . indent_style ( ) ) ;
472
441
473
442
let fmt = ListFormatting {
@@ -518,6 +487,47 @@ pub fn rewrite_array<T: Rewrite + Spanned + ToExpr>(
518
487
Some ( result)
519
488
}
520
489
490
+ fn array_tactic < T : Rewrite + Spanned + ToExpr > (
491
+ context : & RewriteContext ,
492
+ shape : Shape ,
493
+ nested_shape : Shape ,
494
+ exprs : & [ & T ] ,
495
+ items : & [ ListItem ] ,
496
+ bracket_size : usize ,
497
+ ) -> DefinitiveListTactic {
498
+ let has_long_item = items
499
+ . iter ( )
500
+ . any ( |li| li. item . as_ref ( ) . map ( |s| s. len ( ) > 10 ) . unwrap_or ( false ) ) ;
501
+
502
+ match context. config . indent_style ( ) {
503
+ IndentStyle :: Block => {
504
+ match shape. width . checked_sub ( 2 * bracket_size) {
505
+ Some ( width) => {
506
+ let tactic = ListTactic :: LimitedHorizontalVertical (
507
+ context. config . width_heuristics ( ) . array_width ,
508
+ ) ;
509
+ definitive_tactic ( items, tactic, Separator :: Comma , width)
510
+ }
511
+ None => DefinitiveListTactic :: Vertical ,
512
+ }
513
+ }
514
+ IndentStyle :: Visual => {
515
+ if has_long_item || items. iter ( ) . any ( ListItem :: is_multiline) {
516
+ definitive_tactic (
517
+ items,
518
+ ListTactic :: LimitedHorizontalVertical (
519
+ context. config . width_heuristics ( ) . array_width ,
520
+ ) ,
521
+ Separator :: Comma ,
522
+ nested_shape. width ,
523
+ )
524
+ } else {
525
+ DefinitiveListTactic :: Mixed
526
+ }
527
+ }
528
+ }
529
+ }
530
+
521
531
fn nop_block_collapse ( block_str : Option < String > , budget : usize ) -> Option < String > {
522
532
debug ! ( "nop_block_collapse {:?} {}" , block_str, budget) ;
523
533
block_str. map ( |block_str| {
0 commit comments