diff options
| author | Steve Klabnik <steve@steveklabnik.com> | 2015-03-28 16:06:37 -0400 |
|---|---|---|
| committer | Steve Klabnik <steve@steveklabnik.com> | 2015-03-28 16:06:37 -0400 |
| commit | f6c234fb45327c3e96b4fe8902dd7416e0f61dde (patch) | |
| tree | 6210ee2fa3b827021baed86b07a42176a289fbe2 /src/libcore | |
| parent | 242ed0b7c0f6a21096f2cc3e1ad1bdb176d02545 (diff) | |
| download | rust-f6c234fb45327c3e96b4fe8902dd7416e0f61dde.tar.gz rust-f6c234fb45327c3e96b4fe8902dd7416e0f61dde.zip | |
Document properties for Eq + Hash
Fixes #23320
Diffstat (limited to 'src/libcore')
| -rw-r--r-- | src/libcore/hash/mod.rs | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/libcore/hash/mod.rs b/src/libcore/hash/mod.rs index 2feb2f8b1e3..2375ae89650 100644 --- a/src/libcore/hash/mod.rs +++ b/src/libcore/hash/mod.rs @@ -73,6 +73,16 @@ mod sip; /// /// The `H` type parameter is an abstract hash state that is used by the `Hash` /// to compute the hash. +/// +/// If you are also implementing `Eq`, there is an additional property that +/// is important: +/// +/// ```text +/// k1 == k2 -> hash(k1) == hash(k2) +/// ``` +/// +/// In other words, if two keys are equal, their hashes should also be equal. +/// `HashMap` and `HashSet` both rely on this behavior. #[stable(feature = "rust1", since = "1.0.0")] pub trait Hash { /// Feeds this value into the state given, updating the hasher as necessary. |
