Rollup merge of #113139 - joshtriplett:style-clarify-let-else, r=calebcartwright

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.
This commit is contained in:
Matthias Krüger 2023-06-29 05:48:41 +02:00 committed by GitHub
commit c4dc70eb31
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -159,8 +159,8 @@ before the `else`.
If the initializer expression is multi-line, the `else` keyword and opening 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 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 the initializer expression, with a space between them, if and only if all the
true: following are true:
* The initializer expression ends with one or more closing * The initializer expression ends with one or more closing
parentheses, square brackets, and/or braces parentheses, square brackets, and/or braces
@ -209,6 +209,28 @@ fn main() {
else { else {
return; 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;
};
} }
``` ```