Skip to content

Commit

Permalink
Rollup merge of #113139 - joshtriplett:style-clarify-let-else, r=cale…
Browse files Browse the repository at this point in the history
…bcartwright

style-guide: Clarify let-else further

Give some additional examples with multi-line patterns.

Make it clearer to go on to the next case if the conditions aren't met.
  • Loading branch information
matthiaskrgr authored Jun 29, 2023
2 parents 7e1869f + 5abeb80 commit c4dc70e
Showing 1 changed file with 24 additions and 2 deletions.
26 changes: 24 additions & 2 deletions src/doc/style-guide/src/statements.md
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,8 @@ before the `else`.

If the initializer expression is multi-line, the `else` keyword and opening
brace of the block (i.e. `else {`) should be put on the same line as the end of
the initializer expression, with a space between them, if all the following are
true:
the initializer expression, with a space between them, if and only if all the
following are true:

* The initializer expression ends with one or more closing
parentheses, square brackets, and/or braces
Expand Down Expand Up @@ -209,6 +209,28 @@ fn main() {
else {
return;
};

let LongStructName(AnotherStruct {
multi,
line,
pattern,
}) = slice.as_ref()
else {
return;
};

let LongStructName(AnotherStruct {
multi,
line,
pattern,
}) = multi_line_function_call(
arg1,
arg2,
arg3,
arg4,
) else {
return;
};
}
```

Expand Down

0 comments on commit c4dc70e

Please sign in to comment.