From 5abeb801b888a0475a87c03b3428d9cd503a0e74 Mon Sep 17 00:00:00 2001 From: Josh Triplett Date: Wed, 28 Jun 2023 14:56:21 -0700 Subject: [PATCH] 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. --- src/doc/style-guide/src/statements.md | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/src/doc/style-guide/src/statements.md b/src/doc/style-guide/src/statements.md index 9bc521e1c7ba8..a5cd6da10616d 100644 --- a/src/doc/style-guide/src/statements.md +++ b/src/doc/style-guide/src/statements.md @@ -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; + }; } ```