@@ -801,11 +801,11 @@ E.g., `&&Some(foo)` matches, `Foo(4, Bar)` does not.
801
801
802
802
## Combinable expressions
803
803
804
- Where a function call has a single argument, and that argument is formatted
805
- across multiple-lines, format the outer call as if it were a single-line call,
804
+ When the last argument in a function call is formatted across
805
+ multiple-lines, format the outer call as if it were a single-line call,
806
806
if the result fits. Apply the same combining behaviour to any similar
807
807
expressions which have multi-line, block-indented lists of sub-expressions
808
- delimited by parentheses (e.g., macros or tuple struct literals) . E.g.,
808
+ delimited by parentheses, brackets, or braces . E.g.,
809
809
810
810
``` rust
811
811
foo (bar (
@@ -831,20 +831,56 @@ let arr = [combinable(
831
831
an_expr ,
832
832
another_expr ,
833
833
)];
834
+
835
+ let x = Thing (an_expr , another_expr , match cond {
836
+ A => 1 ,
837
+ B => 2 ,
838
+ });
839
+
840
+ let x = format! (" Stuff: {}" , [
841
+ an_expr ,
842
+ another_expr ,
843
+ ]);
834
844
```
835
845
836
846
Apply this behavior recursively.
837
847
838
- For a function with multiple arguments, if the last argument is a multi-line
839
- closure with an explicit block, there are no other closure arguments, and all
840
- the arguments and the first line of the closure fit on the first line, use the
841
- same combining behavior:
848
+ If the last argument is a multi-line closure with an explicit block,
849
+ only apply the combining behavior if there are no other closure arguments.
842
850
843
851
``` rust
852
+ // Combinable
844
853
foo (first_arg , x , | param | {
845
854
action ();
846
855
foo (param )
847
856
})
857
+ // Not combinable, because the closure is not the last argument
858
+ foo (
859
+ first_arg ,
860
+ | param | {
861
+ action ();
862
+ foo (param )
863
+ },
864
+ whatever ,
865
+ )
866
+ // Not combinable, because the first line of the closure does not fit
867
+ foo (
868
+ first_arg ,
869
+ x ,
870
+ move | very_long_param_causing_line_to_overflow | -> Bar {
871
+ action ();
872
+ foo (param )
873
+ },
874
+ )
875
+ // Not combinable, because there is more than one closure argument
876
+ foo (
877
+ first_arg ,
878
+ | x | x . bar (),
879
+ | param | {
880
+ action ();
881
+ foo (param )
882
+ },
883
+ )
848
884
```
849
885
850
886
## Ranges
0 commit comments