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
This commit is contained in:
commit
c2a79fb490
1 changed files with 25 additions and 12 deletions
|
|
@ -138,18 +138,31 @@ Otherwise, the `else` keyword and opening brace should be placed on the next lin
|
|||
For example:
|
||||
|
||||
```rust
|
||||
let Some(x) = abcdef()
|
||||
.foo(
|
||||
"abc",
|
||||
some_really_really_really_long_ident,
|
||||
"ident",
|
||||
"123456",
|
||||
)
|
||||
.bar()
|
||||
.baz()
|
||||
.qux("fffffffffffffffff")
|
||||
else {
|
||||
foo_bar()
|
||||
fn main() {
|
||||
let Some(x) = abcdef()
|
||||
.foo(
|
||||
"abc",
|
||||
some_really_really_really_long_ident,
|
||||
"ident",
|
||||
"123456",
|
||||
)
|
||||
.bar()
|
||||
.baz()
|
||||
.qux("fffffffffffffffff")
|
||||
else {
|
||||
return
|
||||
};
|
||||
|
||||
let Some(x) = some_really_really_really_really_really_really_really_really_really_long_name
|
||||
else {
|
||||
return;
|
||||
};
|
||||
|
||||
let Some(aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa) =
|
||||
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
|
||||
else {
|
||||
return;
|
||||
};
|
||||
}
|
||||
```
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue