mirror of
https://github.com/rust-lang/rust.git
synced 2025-02-13 15:33:53 +00:00
Rollup merge of #114605 - Easyoakland:hash-collection-doc, r=thomcc
Increase clarity about Hash - Eq consistency in HashMap and HashSet docs As discussed [here](https://users.rust-lang.org/t/what-hapens-if-hash-and-partialeq-dont-match-when-using-hashmap/98052/13) the description of logic errors in `HashMap` and `HashSet` does not explicitly apply to ```text k1 == k2 -> hash(k1) == hash(k2) ``` but this is likely what is intended. This PR is a small doc change to correct this. r? rust-lang/libs
This commit is contained in:
commit
0cc4b55a12
@ -49,12 +49,14 @@ use crate::sys;
|
||||
/// ```
|
||||
///
|
||||
/// In other words, if two keys are equal, their hashes must be equal.
|
||||
/// Violating this property is a logic error.
|
||||
///
|
||||
/// It is a logic error for a key to be modified in such a way that the key's
|
||||
/// It is also 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.
|
||||
/// The behavior resulting from such a logic error is not specified, but will
|
||||
///
|
||||
/// The behavior resulting from either logic error is not specified, but will
|
||||
/// be encapsulated to the `HashMap` that observed the logic error and not
|
||||
/// result in undefined behavior. This could include panics, incorrect results,
|
||||
/// aborts, memory leaks, and non-termination.
|
||||
|
@ -24,13 +24,14 @@ use super::map::{map_try_reserve_error, RandomState};
|
||||
/// ```
|
||||
///
|
||||
/// In other words, if two keys are equal, their hashes must be equal.
|
||||
/// Violating this property is a logic error.
|
||||
///
|
||||
///
|
||||
/// It is a logic error for a key to be modified in such a way that the key's
|
||||
/// It is also 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.
|
||||
/// The behavior resulting from such a logic error is not specified, but will
|
||||
///
|
||||
/// The behavior resulting from either logic error is not specified, but will
|
||||
/// be encapsulated to the `HashSet` that observed the logic error and not
|
||||
/// result in undefined behavior. This could include panics, incorrect results,
|
||||
/// aborts, memory leaks, and non-termination.
|
||||
|
Loading…
Reference in New Issue
Block a user