Skip to content

Commit

Permalink
style-guide: Fix chain example to match rustfmt behavior
Browse files Browse the repository at this point in the history
The style guide gave an example of breaking a multi-line chain element
and all subsequent elements to a new line, but that same example and the
accompanying text also had several chain items stacked on the first
line. rustfmt doesn't do this, except when the rule saying to combine

```
shrt
    .y()
```

into

```
shrt.y()
```

applies.
  • Loading branch information
joshtriplett committed Jul 5, 2023
1 parent 5dac6b3 commit 24534cf
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/doc/style-guide/src/expressions.md
Original file line number Diff line number Diff line change
Expand Up @@ -450,12 +450,11 @@ foo(

#### Multi-line elements

If any element in a chain is formatted across multiple lines, then that element
and any later elements must be on their own line. Earlier elements may be kept
on a single line. E.g.,
If any element in a chain is formatted across multiple lines, put that element
and any later elements on their own lines.

```rust
a.b.c()?.d
a.b.c()?
.foo(
an_expr,
another_expr,
Expand Down

0 comments on commit 24534cf

Please sign in to comment.