diff options
| author | Andrew Paseltiner <apaseltiner@gmail.com> | 2015-03-13 13:47:55 -0400 |
|---|---|---|
| committer | Andrew Paseltiner <apaseltiner@gmail.com> | 2015-03-16 09:55:41 -0400 |
| commit | 90f06ae33fdf34e60c29cbd38dd3ec7be6b3badb (patch) | |
| tree | ed7416aa18a4af2fa2c752b32c643181aac4b469 /src/libstd | |
| parent | ee7696383f3423cdd17373ff9e75c01acd8e3417 (diff) | |
| download | rust-90f06ae33fdf34e60c29cbd38dd3ec7be6b3badb.tar.gz rust-90f06ae33fdf34e60c29cbd38dd3ec7be6b3badb.zip | |
document undefined collection behavior with interior mutability
closes #23327
Diffstat (limited to 'src/libstd')
| -rw-r--r-- | src/libstd/collections/hash/map.rs | 5 | ||||
| -rw-r--r-- | src/libstd/collections/hash/set.rs | 6 |
2 files changed, 11 insertions, 0 deletions
diff --git a/src/libstd/collections/hash/map.rs b/src/libstd/collections/hash/map.rs index 18f86901b8f..0892365d9d5 100644 --- a/src/libstd/collections/hash/map.rs +++ b/src/libstd/collections/hash/map.rs @@ -217,6 +217,11 @@ fn test_resize_policy() { /// It is required that the keys implement the `Eq` and `Hash` traits, although /// this can frequently be achieved by using `#[derive(Eq, Hash)]`. /// +/// 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 +/// the `Eq` trait, changes while it is in the map. This is normally only +/// possible through `Cell`, `RefCell`, global state, I/O, or unsafe code. +/// /// Relevant papers/articles: /// /// 1. Pedro Celis. ["Robin Hood Hashing"](https://cs.uwaterloo.ca/research/tr/1986/CS-86-14.pdf) diff --git a/src/libstd/collections/hash/set.rs b/src/libstd/collections/hash/set.rs index 35115ad77fe..de3f080de82 100644 --- a/src/libstd/collections/hash/set.rs +++ b/src/libstd/collections/hash/set.rs @@ -38,6 +38,12 @@ use super::state::HashState; /// HashMap where the value is (). As with the `HashMap` type, a `HashSet` /// requires that the elements implement the `Eq` and `Hash` traits. /// +/// 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 +/// determined by the `Eq` trait, changes while it is in the set. This is +/// normally only possible through `Cell`, `RefCell`, global state, I/O, or +/// unsafe code. +/// /// # Examples /// /// ``` |
