Skip to content

Commit e868eb5

Browse files
JakobDegenfacebook-github-bot
authored andcommitted
strong hash: Clarify docs
Reviewed By: iguridi Differential Revision: D74350789 fbshipit-source-id: 0e592f4b8c24f1b493fcfb829169fdc7f8f7bc04
1 parent 477a5ae commit e868eb5

File tree

1 file changed

+8
-15
lines changed

1 file changed

+8
-15
lines changed

gazebo/strong_hash/src/lib.rs

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -21,21 +21,15 @@ use crate as strong_hash;
2121

2222
mod impls;
2323

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.
2726
///
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.
3330
///
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:
3933
///
4034
/// ```ignore
4135
/// #[derive(StrongHash)]
@@ -46,8 +40,7 @@ mod impls;
4640
/// }
4741
/// ```
4842
///
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:
5144
///
5245
/// ```ignore
5346
/// struct MyStruct {

0 commit comments

Comments
 (0)