about summary refs log tree commit diff
path: root/library
diff options
context:
space:
mode:
authorgewitternacht <60887951+gewitternacht@users.noreply.github.com>2025-08-11 00:05:47 +0200
committerGitHub <noreply@github.com>2025-08-11 00:05:47 +0200
commitfadc961d99f221fd720f97dc9eec61c2332cd451 (patch)
tree8d8b3e8f38d11de53dd2ae22bea23e752a5e3dee /library
parentc72bb70ffd284538519242663fa9443037f4d41e (diff)
downloadrust-fadc961d99f221fd720f97dc9eec61c2332cd451.tar.gz
rust-fadc961d99f221fd720f97dc9eec61c2332cd451.zip
mention `Hash` and `Ord`; refine description of `derive`
Diffstat (limited to 'library')
-rw-r--r--library/core/src/clone.rs12
1 files changed, 8 insertions, 4 deletions
diff --git a/library/core/src/clone.rs b/library/core/src/clone.rs
index 6fcba298a43..b5daa3d41fa 100644
--- a/library/core/src/clone.rs
+++ b/library/core/src/clone.rs
@@ -153,10 +153,14 @@ mod uninit;
 /// Standard library collections such as
 /// [`HashMap`], [`HashSet`], [`BTreeMap`], [`BTreeSet`] and [`BinaryHeap`]
 /// rely on their keys respecting this property for correct behavior.
-///
-/// This property is automatically satisfied when deriving both `Clone` and [`PartialEq`]
-/// using `#[derive(Clone, PartialEq)]` or when additionally deriving [`Eq`]
-/// using `#[derive(Clone, PartialEq, Eq)]`.
+/// Furthermore, these collections require that cloning a key preserves the outcome of the
+/// [`Hash`] and [`Ord`] methods. Thankfully, this follows automatically from `x.clone() == x`
+/// if `Hash` and `Ord` are correctly implemented according to their own requirements.
+///
+/// When deriving both `Clone` and [`PartialEq`] using `#[derive(Clone, PartialEq)]`
+/// or when additionally deriving [`Eq`] using `#[derive(Clone, PartialEq, Eq)]`,
+/// then this property is automatically upheld – provided that it is satisfied by
+/// the underlying types.
 ///
 /// Violating this property is a logic error. The behavior resulting from a logic error is not
 /// specified, but users of the trait must ensure that such logic errors do *not* result in