From 12d7f5b56e23d2d62884e941fa81937ce8799960 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Mon, 2 Aug 2021 15:59:28 +0300 Subject: internal: explain that we don't `ref` in style.md --- docs/dev/style.md | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'docs/dev') 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: -- cgit 1.4.1-3-g733a5