about summary refs log tree commit diff
path: root/src/libstd/collections
diff options
context:
space:
mode:
authorManish Goregaokar <manishsmail@gmail.com>2015-03-29 18:22:15 +0530
committerManish Goregaokar <manishsmail@gmail.com>2015-03-29 18:22:15 +0530
commit5daab4a25be69f2e683961b8b1b6cba567c4eee2 (patch)
treeafa6221abe127afc97be3b31541d1df229a9e421 /src/libstd/collections
parentef94b8a9d3e915318029b83e39af63861ca44952 (diff)
parentf6c234fb45327c3e96b4fe8902dd7416e0f61dde (diff)
downloadrust-5daab4a25be69f2e683961b8b1b6cba567c4eee2.tar.gz
rust-5daab4a25be69f2e683961b8b1b6cba567c4eee2.zip
Rollup merge of #23814 - steveklabnik:gh23320, r=alexcrichton
Fixes #23320
Diffstat (limited to 'src/libstd/collections')
-rw-r--r--src/libstd/collections/hash/map.rs9
-rw-r--r--src/libstd/collections/hash/set.rs11
2 files changed, 18 insertions, 2 deletions
diff --git a/src/libstd/collections/hash/map.rs b/src/libstd/collections/hash/map.rs
index 276959b715d..bc0f109de15 100644
--- a/src/libstd/collections/hash/map.rs
+++ b/src/libstd/collections/hash/map.rs
@@ -214,7 +214,14 @@ fn test_resize_policy() {
 /// overridden with one of the constructors.
 ///
 /// It is required that the keys implement the `Eq` and `Hash` traits, although
-/// this can frequently be achieved by using `#[derive(Eq, Hash)]`.
+/// this can frequently be achieved by using `#[derive(Eq, Hash)]`. If you
+/// implement these yourself, it is important that the following property holds:
+///
+/// ```text
+/// k1 == k2 -> hash(k1) == hash(k2)
+/// ```
+///
+/// In other words, if two keys are equal, their hashes must be equal.
 ///
 /// It is a logic error for a key to be modified in such a way that the key's
 /// hash, as determined by the `Hash` trait, or its equality, as determined by
diff --git a/src/libstd/collections/hash/set.rs b/src/libstd/collections/hash/set.rs
index 9a4b55af4d5..87380471c80 100644
--- a/src/libstd/collections/hash/set.rs
+++ b/src/libstd/collections/hash/set.rs
@@ -34,7 +34,16 @@ use super::state::HashState;
 
 /// An implementation of a hash set using the underlying representation of a
 /// HashMap where the value is (). As with the `HashMap` type, a `HashSet`
-/// requires that the elements implement the `Eq` and `Hash` traits.
+/// requires that the elements implement the `Eq` and `Hash` traits. This can
+/// frequently be achieved by using `#[derive(Eq, Hash)]`. If you implement
+/// these yourself, it is important that the following property holds:
+///
+/// ```text
+/// k1 == k2 -> hash(k1) == hash(k2)
+/// ```
+///
+/// In other words, if two keys are equal, their hashes must be equal.
+///
 ///
 /// It is a logic error for an item to be modified in such a way that the
 /// item's hash, as determined by the `Hash` trait, or its equality, as