Unnamed repository; edit this file 'description' to name the repository.
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 92e79508b6..e11005c560 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.