]> git.lizzy.rs Git - rust.git/blob - src/tools/clippy/src/docs/unit_hash.txt
Auto merge of #104673 - matthiaskrgr:rollup-85f65ov, r=matthiaskrgr
[rust.git] / src / tools / clippy / src / docs / unit_hash.txt
1 ### What it does
2 Detects `().hash(_)`.
3
4 ### Why is this bad?
5 Hashing a unit value doesn't do anything as the implementation of `Hash` for `()` is a no-op.
6
7 ### Example
8 ```
9 match my_enum {
10         Empty => ().hash(&mut state),
11         WithValue(x) => x.hash(&mut state),
12 }
13 ```
14 Use instead:
15 ```
16 match my_enum {
17         Empty => 0_u8.hash(&mut state),
18         WithValue(x) => x.hash(&mut state),
19 }
20 ```