about summary refs log tree commit diff
path: root/src/libstd
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2015-03-29 14:02:28 +0000
committerbors <bors@rust-lang.org>2015-03-29 14:02:28 +0000
commitb27ba527c5cee06f43967daf3a0dd01a2258a0fa (patch)
tree2d31bf590f7da7173d7ffce609c6aa2a22eb97f6 /src/libstd
parentea03ad961669e69d57cb0ae1a48b53b4b49a8342 (diff)
parent9147463678341db09c36d1a24a643b8ba4e3be73 (diff)
downloadrust-b27ba527c5cee06f43967daf3a0dd01a2258a0fa.tar.gz
rust-b27ba527c5cee06f43967daf3a0dd01a2258a0fa.zip
Auto merge of #23831 - Manishearth:rollup, r=Manishearth
- Successful merges: #23811, #23814, #23817, #23821, #23829
- Failed merges: 
Diffstat (limited to 'src/libstd')
-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