]> git.lizzy.rs Git - rust.git/blob - src/docs/implicit_hasher.txt
Auto merge of #9421 - xphoniex:fix-#9420, r=giraffate
[rust.git] / src / docs / implicit_hasher.txt
1 ### What it does
2 Checks for public `impl` or `fn` missing generalization
3 over different hashers and implicitly defaulting to the default hashing
4 algorithm (`SipHash`).
5
6 ### Why is this bad?
7 `HashMap` or `HashSet` with custom hashers cannot be
8 used with them.
9
10 ### Known problems
11 Suggestions for replacing constructors can contain
12 false-positives. Also applying suggestions can require modification of other
13 pieces of code, possibly including external crates.
14
15 ### Example
16 ```
17 impl<K: Hash + Eq, V> Serialize for HashMap<K, V> { }
18
19 pub fn foo(map: &mut HashMap<i32, i32>) { }
20 ```
21 could be rewritten as
22 ```
23 impl<K: Hash + Eq, V, S: BuildHasher> Serialize for HashMap<K, V, S> { }
24
25 pub fn foo<S: BuildHasher>(map: &mut HashMap<i32, i32, S>) { }
26 ```