You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
style-guide: Rewrite let-else section for clarity, without changing formatting
The section as written did not cover all cases, and left some of them
implicit. Rewrite it to systematically cover all cases. Place examples
immediately following the corresponding case.
In the process, reorder to move the simplest cases first: start with
single-line and add progressively more line breaks.
This does not change the meaning of the section at all, and in
particular does not change the defined style for let-else statements.
If the initializer expression is multi-line, the `else` keyword and opening
159
+
brace of the block (i.e. `else {`) should be put on the same line as the end of
160
+
the initializer expression, with a space between them, if all the following are
161
+
true:
115
162
116
163
* The initializer expression ends with one or more closing
117
164
parentheses, square brackets, and/or braces
118
165
* There is nothing else on that line
119
-
* That line is not indented beyond the indent of the first line containing the `let` keyword
166
+
* That line has the same indentation level as the initial `let` keyword.
120
167
121
168
For example:
122
169
@@ -133,7 +180,9 @@ let Some(x) = y.foo(
133
180
}
134
181
```
135
182
136
-
Otherwise, the `else` keyword and opening brace should be placed on the next line after the end of the initializer expression, and should not be indented (the `else` keyword should be aligned with the `let` keyword).
183
+
Otherwise, the `else` keyword and opening brace should be placed on the next
184
+
line after the end of the initializer expression, and the `else` keyword should
185
+
have the same indentation level as the `let` keyword.
0 commit comments