Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit c2a79fb

Browse files
Rollup merge of #110426 - calebcartwright:style-let-else-examples, r=compiler-errors
docs(style): add more let-else examples Adding a few more examples for increased clarity based on subsequent discussion that arose after implementation work began. Will need approval from t-style, but also cc ```@ytmimi``` to make sure these examples don't contradict any examples we've been incorporating as part of the rustfmt implementation
2 parents 6ce2273 + 0776a4b commit c2a79fb

File tree

1 file changed

+25
-12
lines changed

1 file changed

+25
-12
lines changed

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

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -138,18 +138,31 @@ Otherwise, the `else` keyword and opening brace should be placed on the next lin
138138
For example:
139139

140140
```rust
141-
let Some(x) = abcdef()
142-
.foo(
143-
"abc",
144-
some_really_really_really_long_ident,
145-
"ident",
146-
"123456",
147-
)
148-
.bar()
149-
.baz()
150-
.qux("fffffffffffffffff")
151-
else {
152-
foo_bar()
141+
fn main() {
142+
let Some(x) = abcdef()
143+
.foo(
144+
"abc",
145+
some_really_really_really_long_ident,
146+
"ident",
147+
"123456",
148+
)
149+
.bar()
150+
.baz()
151+
.qux("fffffffffffffffff")
152+
else {
153+
return
154+
};
155+
156+
let Some(x) = some_really_really_really_really_really_really_really_really_really_long_name
157+
else {
158+
return;
159+
};
160+
161+
let Some(aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa) =
162+
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
163+
else {
164+
return;
165+
};
153166
}
154167
```
155168

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /