rust/src/docs/unit_hash.txt
2022-09-09 13:36:26 +02:00

20 lines
No EOL
370 B
Text

### What it does
Detects `().hash(_)`.
### Why is this bad?
Hashing a unit value doesn't do anything as the implementation of `Hash` for `()` is a no-op.
### Example
```
match my_enum {
Empty => ().hash(&mut state),
WithValue(x) => x.hash(&mut state),
}
```
Use instead:
```
match my_enum {
Empty => 0_u8.hash(&mut state),
WithValue(x) => x.hash(&mut state),
}
```