diff options
| author | Aleksey Kladov <aleksey.kladov@gmail.com> | 2021-09-25 14:10:25 +0300 |
|---|---|---|
| committer | Aleksey Kladov <aleksey.kladov@gmail.com> | 2021-09-25 14:10:25 +0300 |
| commit | d72f7cf3af4ec652ae65cbd896993036a703a124 (patch) | |
| tree | 4677024e2a348d0bd531a8018861a34179567868 /docs/dev | |
| parent | 1567bbb73e48d897a55ec8281ab6191550fd6684 (diff) | |
| download | rust-d72f7cf3af4ec652ae65cbd896993036a703a124.tar.gz rust-d72f7cf3af4ec652ae65cbd896993036a703a124.zip | |
internal: add => () rule; emphasize `n_items` rule
Diffstat (limited to 'docs/dev')
| -rw-r--r-- | docs/dev/style.md | 22 |
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. |
