Skip to content

Commit

Permalink
Revert "do not combine if multiple exprs of the same kind"
Browse files Browse the repository at this point in the history
This reverts commit b754b33.
  • Loading branch information
pitaj committed Nov 4, 2023
1 parent b754b33 commit d2791fa
Showing 1 changed file with 1 addition and 44 deletions.
45 changes: 1 addition & 44 deletions src/doc/style-guide/src/expressions.md
Original file line number Diff line number Diff line change
Expand Up @@ -850,51 +850,8 @@ let x = func(an_expr, another_expr, SomeStruct {

Apply this behavior recursively.

```rust
foo(an_expr, bar(another_expr, SomeStruct(SomeEnum::Variant {
field: this_is_long,
another_field: 123,
})));

Thing(an_expr, do_something_with(another_expr, [
one,
two,
three,
]));
```

Do not apply the combining behavior if one of the prior arguments is the
same kind of expression as the last argument.

```rust
// The `[h, v + 0.1, 0.0]` sub-array is not combinable, because
// there is a previous sub-array in the outer array.
func(an_expr, &[
[h - 0.1, v, 0.0],
[h + 0.1, v, 0.0],
[h, v + 0.1, 0.0],
]);

// The `Thing` field struct expression is not combinable, because
// there is a previous field struct expression in the arguments to `run`.
func(an_expr, run(
Foo { x: 1, y: 2, z: 3 },
Bar { x: 1, y: 2, z: 3 },
Thing { x: 1, y: 2, z: 3 },
));

// The `(more_exprs, last_expr)` tuple is not combinable, because
// there is a previous tuple in the array.
func(an_expr, [
(another_expr, third_expr),
(expr_four, fifth_expr),
(more_exprs, last_expr),
]);
```

If the last argument is a multi-line closure with an explicit block,
only apply the combining behavior if there are no other closure arguments,
regardless of whether they have explicit blocks or occupy multiple lines.
only apply the combining behavior if there are no other closure arguments.

```rust
// Combinable
Expand Down

0 comments on commit d2791fa

Please sign in to comment.