Skip to content

Commit 5abeb80

Browse files
committed
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.
1 parent eb76764 commit 5abeb80

File tree

1 file changed

+24
-2
lines changed

1 file changed

+24
-2
lines changed

src/doc/style-guide/src/statements.md

+24-2
Original file line numberDiff line numberDiff line change
@@ -159,8 +159,8 @@ before the `else`.
159159

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

165165
* The initializer expression ends with one or more closing
166166
parentheses, square brackets, and/or braces
@@ -209,6 +209,28 @@ fn main() {
209209
else {
210210
return;
211211
};
212+
213+
let LongStructName(AnotherStruct {
214+
multi,
215+
line,
216+
pattern,
217+
}) = slice.as_ref()
218+
else {
219+
return;
220+
};
221+
222+
let LongStructName(AnotherStruct {
223+
multi,
224+
line,
225+
pattern,
226+
}) = multi_line_function_call(
227+
arg1,
228+
arg2,
229+
arg3,
230+
arg4,
231+
) else {
232+
return;
233+
};
212234
}
213235
```
214236

0 commit comments

Comments
 (0)