Skip to content

Commit e4a0b48

Browse files
committed
Make note about traits that can be derived
in their API docs Fixes #29711
1 parent 57c8a3e commit e4a0b48

File tree

5 files changed

+18
-0
lines changed

5 files changed

+18
-0
lines changed

src/libcore/clone.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
use marker::Sized;
2525

2626
/// A common trait for cloning an object.
27+
///
28+
/// This trait can be used with `#[derive]`.
2729
#[stable(feature = "rust1", since = "1.0.0")]
2830
pub trait Clone : Sized {
2931
/// Returns a copy of the value.

src/libcore/cmp.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ use option::Option::{self, Some};
4343
/// in terms of it by default. Any manual implementation of `ne` *must* respect
4444
/// the rule that `eq` is a strict inverse of `ne`; that is, `!(a == b)` if and
4545
/// only if `a != b`.
46+
///
47+
/// This trait can be used with `#[derive]`.
4648
#[lang = "eq"]
4749
#[stable(feature = "rust1", since = "1.0.0")]
4850
pub trait PartialEq<Rhs: ?Sized = Self> {
@@ -69,6 +71,8 @@ pub trait PartialEq<Rhs: ?Sized = Self> {
6971
///
7072
/// This property cannot be checked by the compiler, and therefore `Eq` implies
7173
/// `PartialEq`, and has no extra methods.
74+
///
75+
/// This trait can be used with `#[derive]`.
7276
#[stable(feature = "rust1", since = "1.0.0")]
7377
pub trait Eq: PartialEq<Self> {
7478
// FIXME #13101: this method is used solely by #[deriving] to
@@ -171,6 +175,8 @@ impl Ordering {
171175
/// - transitive, `a < b` and `b < c` implies `a < c`. The same must hold for both `==` and `>`.
172176
///
173177
/// When this trait is `derive`d, it produces a lexicographic ordering.
178+
///
179+
/// This trait can be used with `#[derive]`.
174180
#[stable(feature = "rust1", since = "1.0.0")]
175181
pub trait Ord: Eq + PartialOrd<Self> {
176182
/// This method returns an `Ordering` between `self` and `other`.
@@ -227,6 +233,8 @@ impl PartialOrd for Ordering {
227233
/// However it remains possible to implement the others separately for types which do not have a
228234
/// total order. For example, for floating point numbers, `NaN < 0 == false` and `NaN >= 0 ==
229235
/// false` (cf. IEEE 754-2008 section 5.11).
236+
///
237+
/// This trait can be used with `#[derive]`.
230238
#[lang = "ord"]
231239
#[stable(feature = "rust1", since = "1.0.0")]
232240
pub trait PartialOrd<Rhs: ?Sized = Self>: PartialEq<Rhs> {

src/libcore/fmt/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,8 @@ impl<'a> Display for Arguments<'a> {
300300
///
301301
/// [module]: ../../std/fmt/index.html
302302
///
303+
/// This trait can be used with `#[derive]`.
304+
///
303305
/// # Examples
304306
///
305307
/// Deriving an implementation:

src/libcore/hash/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,8 @@ mod sip;
9393
///
9494
/// In other words, if two keys are equal, their hashes should also be equal.
9595
/// `HashMap` and `HashSet` both rely on this behavior.
96+
///
97+
/// This trait can be used with `#[derive]`.
9698
#[stable(feature = "rust1", since = "1.0.0")]
9799
pub trait Hash {
98100
/// Feeds this value into the state given, updating the hasher as necessary.

src/libcore/marker.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,10 @@ pub trait Unsize<T: ?Sized> {
165165
/// to consider though: if you think your type may _not_ be able to implement `Copy` in the future,
166166
/// then it might be prudent to not implement `Copy`. This is because removing `Copy` is a breaking
167167
/// change: that second example would fail to compile if we made `Foo` non-`Copy`.
168+
///
169+
/// # Derivable
170+
///
171+
/// This trait can be used with `#[derive]`.
168172
#[stable(feature = "rust1", since = "1.0.0")]
169173
#[lang = "copy"]
170174
pub trait Copy : Clone {

0 commit comments

Comments
 (0)