From d72f7cf3af4ec652ae65cbd896993036a703a124 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sat, 25 Sep 2021 14:10:25 +0300 Subject: internal: add => () rule; emphasize `n_items` rule --- docs/dev/style.md | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) (limited to 'docs/dev') diff --git a/docs/dev/style.md b/docs/dev/style.md index 92e79508b6d..e11005c5604 100644 --- a/docs/dev/style.md +++ b/docs/dev/style.md @@ -849,7 +849,7 @@ Default names: * `res` -- "result of the function" local variable * `it` -- I don't really care about the name -* `n_foo` -- number of foos +* `n_foos` -- number of foos (prefer this to `foo_count`) * `foo_idx` -- index of `foo` Many names in rust-analyzer conflict with keywords. @@ -969,6 +969,26 @@ Don't use the `ref` keyword. 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). +## Empty Match Arms + +Ues `=> (),` when a match arm is intentionally empty: + +```rust +// GOOD +match result { + Ok(_) => (), + Err(err) => error!("{}", err), +} + +// BAD +match result { + Ok(_) => {} + Err(err) => error!("{}", err), +} +``` + +**Rationale:** consistency. + ## Functional Combinators Use high order monadic combinators like `map`, `then` when they are a natural choice; don't bend the code to fit into some combinator. -- cgit 1.4.1-3-g733a5