diff options
| author | Caleb Cartwright <caleb.cartwright@outlook.com> | 2023-04-16 14:48:36 -0500 |
|---|---|---|
| committer | Caleb Cartwright <caleb.cartwright@outlook.com> | 2023-04-26 14:58:49 -0500 |
| commit | 0776a4bf27bd8fe813e33354b43b5b50e5469852 (patch) | |
| tree | f30a80836bff0bf369ecc02552f52b9fc65ae1c7 | |
| parent | c609da59d9fc05b1c7dc879d79700ccd8140b5fc (diff) | |
| download | rust-0776a4bf27bd8fe813e33354b43b5b50e5469852.tar.gz rust-0776a4bf27bd8fe813e33354b43b5b50e5469852.zip | |
docs(style): add more let-else examples
Co-authored-by: Michael Goulet <michael@errs.io>
| -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; + }; } ``` |
