summaryrefslogtreecommitdiffstats
path: root/src/tools/clippy/src/docs/manual_assert.txt
blob: 93653081a2ce08833423201991d8ee71b2bf1484 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
### What it does
Detects `if`-then-`panic!` that can be replaced with `assert!`.

### Why is this bad?
`assert!` is simpler than `if`-then-`panic!`.

### Example
```
let sad_people: Vec<&str> = vec![];
if !sad_people.is_empty() {
    panic!("there are sad people: {:?}", sad_people);
}
```
Use instead:
```
let sad_people: Vec<&str> = vec![];
assert!(sad_people.is_empty(), "there are sad people: {:?}", sad_people);
```