@@ -390,44 +390,98 @@ fn example() {
390
390
```
391
391
392
392
## ` chains_block_parent_indent_children `
393
- Determines whether to indent the child chain items of a chain that beings with a block-like parent element when ` indent_style ` is ` Block ` .
393
+ Determines whether to indent the child chain items of a chain that begins with a block-like parent element when ` indent_style ` is ` Block ` .
394
394
395
- - ** Default value** : ` false `
396
- - ** Possible values** : ` true ` , ` false `
395
+ - ** Default value** : ` "OnlyWithParent" `
396
+ - ** Possible values** : ` "Always" ` , ` "OnlyWithParent" `
397
397
- ** Stable** : No (tracking issue: ...)
398
398
399
- #### ` false ` (default):
399
+ #### ` OnlyWithParent ` (default):
400
+ Only indent the children chain elements of a block-like parent element if the parent's body was indented.
400
401
401
402
``` rust
403
+ // chains_block_parent_indent_parent_item: "OnlyTupleLitsAndSimpleCalls"
404
+ #![rustfmt:: skip]
402
405
fn example () {
403
- StructA {
404
- test_test : some_value ,
405
- }
406
- . foo ()
406
+ let all = very_very_very_very_very_long_fun_name (
407
+ very_very_very_very_very_very_very_very_very_long_var_name ,
408
+ )
409
+ . iter ()
410
+ . map (| x | x + very_very_very_very_very_very_long_var_name );
411
+
412
+ foo (| x | {
413
+ // ....
414
+ })
407
415
. bar ()
408
416
. baz ()
409
- . qux ();
417
+ . unwrap ();
418
+
419
+ StructA {
420
+ test_test : some_value ,
421
+ }
422
+ . do_stuff (StructB {
423
+ test_test_b : other_value ,
424
+ })
425
+ . foo ()
426
+ . aaa_aaa ();
427
+
428
+ let y = if some_condition {
429
+ // foo
430
+ val1
431
+ } else {
432
+ // bar
433
+ val2
434
+ }
435
+ . method_call ()
436
+ . other_call ()
437
+ . another ();
410
438
}
411
439
```
412
440
413
- #### ` true ` :
441
+ #### ` Always ` :
442
+ Always indent the children chain elements of a block-like parent element, regardless of whether the parent element body was indented.
414
443
415
444
``` rust
416
445
fn example () {
446
+ let all = very_very_very_very_very_long_fun_name (
447
+ very_very_very_very_very_very_very_very_very_long_var_name ,
448
+ )
449
+ . iter ()
450
+ . map (| x | x + very_very_very_very_very_very_long_var_name );
451
+
452
+ foo (| x | {
453
+ // ....
454
+ })
455
+ . bar ()
456
+ . baz ()
457
+ . unwrap ();
458
+
417
459
StructA {
418
460
test_test : some_value ,
419
461
}
462
+ . do_stuff (StructB {
463
+ test_test_b : other_value ,
464
+ })
420
465
. foo ()
421
- . bar ()
422
- . baz ()
423
- . qux ();
466
+ . aaa_aaa ();
467
+
468
+ let y = if some_condition {
469
+ // foo
470
+ val1
471
+ } else {
472
+ // bar
473
+ val2
474
+ }
475
+ . method_call ()
476
+ . other_call ()
477
+ . another ();
424
478
}
425
479
```
426
480
427
- See also: [ ` indent_style ` ] ( #indent_style ) .
481
+ See also: [ ` indent_style ` ] ( #indent_style ) , [ ` chains_block_parent_indent_parent_item ` ] ( #chains_block_parent_indent_parent_item ) .
428
482
429
483
## ` chains_block_parent_indent_parent_item `
430
- Determines whether block-like chain parents are indented when ` indent_style ` is ` Block ` .
484
+ Determines whether the body of block-like chain parents are indented when ` indent_style ` is ` Block ` .
431
485
432
486
- ** Default value** : ` "Never" `
433
487
- ** Possible values** : ` "Always" ` , ` "Never" ` , ` "OnlySimpleCalls" ` , ` "OnlyTupleLitsAndSimpleCalls" `
@@ -475,9 +529,6 @@ fn example() {
475
529
The body of block-like parent chain elements are always indented.
476
530
477
531
``` rust
478
- #![rustfmt:: skip]
479
- // chains_block_parent_indent_children: true
480
-
481
532
fn example () {
482
533
let all = very_very_very_very_very_long_fun_name (
483
534
very_very_very_very_very_very_very_very_very_long_var_name ,
@@ -501,7 +552,7 @@ fn example() {
501
552
)
502
553
. bbb_bbb ()
503
554
. ccc_ccc ();
504
-
555
+
505
556
foo (| x | {
506
557
// ....
507
558
})
@@ -515,9 +566,6 @@ fn example() {
515
566
The body of block-like parent chain elements are only indented when the parent is a simple call-like chain item, such as a method call with no multiline block like arguments (like a closure).
516
567
517
568
``` rust
518
- #![rustfmt:: skip]
519
- // chains_block_parent_indent_children: true
520
-
521
569
fn example () {
522
570
let all = very_very_very_very_very_long_fun_name (
523
571
very_very_very_very_very_very_very_very_very_long_var_name ,
@@ -528,36 +576,33 @@ fn example() {
528
576
StructA {
529
577
test_test : some_value ,
530
578
}
531
- . do_stuff (StructB {
579
+ . do_stuff (StructB {
580
+ test_test_b : other_value ,
581
+ })
582
+ . aaa_aaa ()
583
+ . do_stuff (
584
+ StructB {
532
585
test_test_b : other_value ,
533
- })
534
- . aaa_aaa ()
535
- . do_stuff (
536
- StructB {
537
- test_test_b : other_value ,
538
- }
539
- . ddd_ddd ()
540
- . eee_eee (),
541
- )
542
- . bbb_bbb ()
543
- . ccc_ccc ();
586
+ }
587
+ . ddd_ddd ()
588
+ . eee_eee (),
589
+ )
590
+ . bbb_bbb ()
591
+ . ccc_ccc ();
544
592
545
593
foo (| x | {
546
594
// ....
547
595
})
548
- . bar ()
549
- . baz ()
550
- . unwrap ();
596
+ . bar ()
597
+ . baz ()
598
+ . unwrap ();
551
599
}
552
600
```
553
601
554
602
#### ` "OnlyTupleLitsAndSimpleCalls" ` :
555
603
The body of block-like parent chain elements are only indented when the parent is a tuple literal, or a simple call-like chain item, such as a method call with no multiline block like arguments (like a closure).
556
604
557
605
``` rust
558
- #![rustfmt:: skip]
559
- // chains_block_parent_indent_children: true
560
-
561
606
fn example () {
562
607
let all = very_very_very_very_very_long_fun_name (
563
608
very_very_very_very_very_very_very_very_very_long_var_name ,
@@ -585,9 +630,9 @@ fn example() {
585
630
foo (| x | {
586
631
// ....
587
632
})
588
- . bar ()
589
- . baz ()
590
- . unwrap ();
633
+ . bar ()
634
+ . baz ()
635
+ . unwrap ();
591
636
}
592
637
```
593
638
0 commit comments