mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-08-30 23:27:24 +00:00
Remove conflicting advice
This commit is contained in:
parent
b06ce60086
commit
7bbbff0ba3
1 changed files with 0 additions and 16 deletions
|
@ -236,22 +236,6 @@ In the "Good" version, the precondition check and usage are checked in the same
|
|||
|
||||
**Rationale:** non-local code properties degrade under change.
|
||||
|
||||
When checking a boolean precondition, prefer `if !invariant` to `if negated_invariant`:
|
||||
|
||||
```rust
|
||||
// GOOD
|
||||
if !(idx < len) {
|
||||
return None;
|
||||
}
|
||||
|
||||
// BAD
|
||||
if idx >= len {
|
||||
return None;
|
||||
}
|
||||
```
|
||||
|
||||
**Rationale:** it's useful to see the invariant relied upon by the rest of the function clearly spelled out.
|
||||
|
||||
## Control Flow
|
||||
|
||||
As a special case of the previous rule, do not hide control flow inside functions, push it to the caller:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue