diff options
| author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2021-08-02 13:00:07 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-08-02 13:00:07 +0000 |
| commit | 0d56ff2a02b5d490058f9ea2e6da8d9f44859c0b (patch) | |
| tree | 2ff0abc5e29624ba33c96ded3f72735e832ce928 /docs/dev | |
| parent | d6f2352a084ad405f1380c7b9389aa8ddf326760 (diff) | |
| parent | 12d7f5b56e23d2d62884e941fa81937ce8799960 (diff) | |
| download | rust-0d56ff2a02b5d490058f9ea2e6da8d9f44859c0b.tar.gz rust-0d56ff2a02b5d490058f9ea2e6da8d9f44859c0b.zip | |
Merge #9758
9758: internal: explain that we don't `ref` in style.md r=matklad a=matklad bors r+ 🤖 Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
Diffstat (limited to 'docs/dev')
| -rw-r--r-- | docs/dev/style.md | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/docs/dev/style.md b/docs/dev/style.md index 6309fd02ce4..d5340e2b8e3 100644 --- a/docs/dev/style.md +++ b/docs/dev/style.md @@ -915,6 +915,15 @@ if let Some(expected_type) = ctx.expected_type.as_ref() { **Rationale:** `match` is almost always more compact. The `else` branch can get a more precise pattern: `None` or `Err(_)` instead of `_`. +## Match Ergonomics + +Don't use the `ref` keyword. + +**Rationale:** consistency & simplicity. +`ref` was required before [match ergonomics](https://github.com/rust-lang/rfcs/blob/master/text/2005-match-ergonomics.md). +Today, it is redundant. +Between `ref` and mach ergonomics, the latter is more ergonomic in most cases, and is simpler (does not require a keyword). + ## Helper Functions Avoid creating singe-use helper functions: |
