diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2023-04-27 15:10:52 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-04-27 15:10:52 +0200 |
| commit | c2a79fb490201e81b3d90191c8462dd2264ec174 (patch) | |
| tree | 282bb70289ef3b9813e894b0cf6750ffcb0daee1 /src | |
| parent | 6ce22733b973355573efd1e6294e585460e90e17 (diff) | |
| parent | 0776a4bf27bd8fe813e33354b43b5b50e5469852 (diff) | |
| download | rust-c2a79fb490201e81b3d90191c8462dd2264ec174.tar.gz rust-c2a79fb490201e81b3d90191c8462dd2264ec174.zip | |
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
Diffstat (limited to 'src')
| -rw-r--r-- | src/doc/style-guide/src/statements.md | 37 |
1 files changed, 25 insertions, 12 deletions
diff --git a/src/doc/style-guide/src/statements.md b/src/doc/style-guide/src/statements.md index 4ab1c36f976..671e6d31a57 100644 --- a/src/doc/style-guide/src/statements.md +++ b/src/doc/style-guide/src/statements.md @@ -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; + }; } ``` |
