syle-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.
This commit is contained in:
Josh Triplett 2023-06-28 14:56:21 -07:00
parent eb76764ea4
commit 5abeb801b8

View File

@ -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
@ -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;
};
}
```