@@ -21,21 +21,15 @@ use crate as strong_hash;
21
21
22
22
mod impls;
23
23
24
- /// `StrongHash`` is a trait that is notionally similar to `std::hash::Hash`,
25
- /// but carries the implicit expectation that the hash that will be produced
26
- /// should be as perturbed as possible.
24
+ /// `StrongHash`` is a trait that is notionally similar to `std::hash::Hash`, but carries the
25
+ /// implicit expectation that the hash that will be produced should be as perturbed as possible.
27
26
///
28
- /// When implementing `StrongHash` for an object, you should always hash the entire object
29
- /// and not a subset or a lossy representation of the object unless you are hashing another
30
- /// cryptographic hash of the object. If you do the latter, a good rule of thumb
31
- /// is that you should feel comfortable also using that same hash for equality
32
- /// checks.
27
+ /// `StrongHash` must be implemented such that - when combined with a crypto hasher - the hash value
28
+ /// is suitable to use for equality checks. That means fields must not be omitted and pre-computed
29
+ /// hash values cannot be used if the hasher used for them is weak.
33
30
///
34
- /// By default, `StrongHash` is implemented for most rust types that implement
35
- /// `std::hash::Hash`. including all primitive types, strings, and vectors.
36
- ///
37
- /// `StrongHash` can be derived on enums and structs if all of their members implement
38
- /// `StrongHash`. For example:
31
+ /// `StrongHash` can be derived on enums and structs if all of their members implement `StrongHash`.
32
+ /// For example:
39
33
///
40
34
/// ```ignore
41
35
/// #[derive(StrongHash)]
@@ -46,8 +40,7 @@ mod impls;
46
40
/// }
47
41
/// ```
48
42
///
49
- /// `StrongHash` can also be implemented manually similar to std::hash::Hash. For
50
- /// example:
43
+ /// `StrongHash` can also be implemented manually similar to std::hash::Hash. For example:
51
44
///
52
45
/// ```ignore
53
46
/// struct MyStruct {
0 commit comments