about summary refs log tree commit diff
path: root/docs/dev/style.md
diff options
context:
space:
mode:
authorAleksey Kladov <aleksey.kladov@gmail.com>2021-09-25 14:10:25 +0300
committerAleksey Kladov <aleksey.kladov@gmail.com>2021-09-25 14:10:25 +0300
commitd72f7cf3af4ec652ae65cbd896993036a703a124 (patch)
tree4677024e2a348d0bd531a8018861a34179567868 /docs/dev/style.md
parent1567bbb73e48d897a55ec8281ab6191550fd6684 (diff)
downloadrust-d72f7cf3af4ec652ae65cbd896993036a703a124.tar.gz
rust-d72f7cf3af4ec652ae65cbd896993036a703a124.zip
internal: add => () rule; emphasize `n_items` rule
Diffstat (limited to 'docs/dev/style.md')
-rw-r--r--docs/dev/style.md22
1 files changed, 21 insertions, 1 deletions
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.