diff options
| author | Philipp Krones <hello@philkrones.com> | 2022-09-09 13:36:26 +0200 |
|---|---|---|
| committer | Philipp Krones <hello@philkrones.com> | 2022-09-09 13:36:26 +0200 |
| commit | 98bf99e2f8cf8b357d63a67ce67d5fc5ceef8b3c (patch) | |
| tree | 9737ff22b257f29282e7538d9ecb264451a3c1c0 /src/docs/implicit_hasher.txt | |
| parent | 854f751b263dfac06dc3f635f8a9f92b8bc51da6 (diff) | |
Merge commit 'b52fb5234cd7c11ecfae51897a6f7fa52e8777fc' into clippyup
Diffstat (limited to 'src/docs/implicit_hasher.txt')
| -rw-r--r-- | src/docs/implicit_hasher.txt | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/src/docs/implicit_hasher.txt b/src/docs/implicit_hasher.txt new file mode 100644 index 00000000000..0c1f76620f5 --- /dev/null +++ b/src/docs/implicit_hasher.txt @@ -0,0 +1,26 @@ +### What it does +Checks for public `impl` or `fn` missing generalization +over different hashers and implicitly defaulting to the default hashing +algorithm (`SipHash`). + +### Why is this bad? +`HashMap` or `HashSet` with custom hashers cannot be +used with them. + +### Known problems +Suggestions for replacing constructors can contain +false-positives. Also applying suggestions can require modification of other +pieces of code, possibly including external crates. + +### Example +``` +impl<K: Hash + Eq, V> Serialize for HashMap<K, V> { } + +pub fn foo(map: &mut HashMap<i32, i32>) { } +``` +could be rewritten as +``` +impl<K: Hash + Eq, V, S: BuildHasher> Serialize for HashMap<K, V, S> { } + +pub fn foo<S: BuildHasher>(map: &mut HashMap<i32, i32, S>) { } +``` \ No newline at end of file |
