@@ -35,7 +35,7 @@ use self::Ordering::*;
3535///
3636/// This trait allows for partial equality, for types that do not have a full
3737/// equivalence relation. For example, in floating point numbers `NaN != NaN`,
38- /// so floating point types implement `PartialEq` but not `Eq`.
38+ /// so floating point types implement `PartialEq` but not [ `Eq`] .
3939///
4040/// Formally, the equality must be (for all `a`, `b` and `c`):
4141///
@@ -55,12 +55,12 @@ use self::Ordering::*;
5555///
5656/// ## How can I implement `PartialEq`?
5757///
58- /// PartialEq only requires the `eq` method to be implemented; `ne` is defined
59- /// in terms of it by default. Any manual implementation of `ne` *must* respect
60- /// the rule that `eq` is a strict inverse of `ne`; that is, `!(a == b)` if and
58+ /// ` PartialEq` only requires the [ `eq`] method to be implemented; [ `ne`] is defined
59+ /// in terms of it by default. Any manual implementation of [ `ne`] *must* respect
60+ /// the rule that [ `eq`] is a strict inverse of [ `ne`] ; that is, `!(a == b)` if and
6161/// only if `a != b`.
6262///
63- /// Implementations of `PartialEq`, `PartialOrd`, and `Ord` *must* agree with
63+ /// Implementations of `PartialEq`, [ `PartialOrd`] , and [ `Ord`] *must* agree with
6464/// each other. It's easy to accidentally make them disagree by deriving some
6565/// of the traits and manually implementing others.
6666///
@@ -190,6 +190,9 @@ use self::Ordering::*;
190190/// assert_eq!(x == y, false);
191191/// assert_eq!(x.eq(&y), false);
192192/// ```
193+ ///
194+ /// [`eq`]: PartialEq::eq
195+ /// [`ne`]: PartialEq::ne
193196#[ lang = "eq" ]
194197#[ stable( feature = "rust1" , since = "1.0.0" ) ]
195198#[ doc( alias = "==" ) ]
@@ -233,7 +236,7 @@ pub macro PartialEq($item:item) {
233236/// - transitive: `a == b` and `b == c` implies `a == c`.
234237///
235238/// This property cannot be checked by the compiler, and therefore `Eq` implies
236- /// `PartialEq`, and has no extra methods.
239+ /// [ `PartialEq`] , and has no extra methods.
237240///
238241/// ## Derivable
239242///
@@ -370,6 +373,7 @@ impl Ordering {
370373 /// Chains two orderings.
371374 ///
372375 /// Returns `self` when it's not `Equal`. Otherwise returns `other`.
376+ ///
373377 /// # Examples
374378 ///
375379 /// ```
@@ -442,10 +446,12 @@ impl Ordering {
442446
443447/// A helper struct for reverse ordering.
444448///
445- /// This struct is a helper to be used with functions like `Vec::sort_by_key` and
449+ /// This struct is a helper to be used with functions like [ `Vec::sort_by_key`] and
446450/// can be used to reverse order a part of a key.
447451///
448- /// Example usage:
452+ /// [`Vec::sort_by_key`]: ../../std/vec/struct.Vec.html#method.sort_by_key
453+ ///
454+ /// # Examples
449455///
450456/// ```
451457/// use std::cmp::Reverse;
@@ -506,12 +512,12 @@ impl<T: Ord> Ord for Reverse<T> {
506512///
507513/// ## How can I implement `Ord`?
508514///
509- /// `Ord` requires that the type also be `PartialOrd` and `Eq` (which requires `PartialEq`).
515+ /// `Ord` requires that the type also be [ `PartialOrd`] and [ `Eq`] (which requires [ `PartialEq`] ).
510516///
511- /// Then you must define an implementation for `cmp()` . You may find it useful to use
512- /// `cmp()` on your type's fields.
517+ /// Then you must define an implementation for [ `cmp`] . You may find it useful to use
518+ /// [ `cmp`] on your type's fields.
513519///
514- /// Implementations of `PartialEq`, `PartialOrd`, and `Ord` *must*
520+ /// Implementations of [ `PartialEq`], [ `PartialOrd`] , and `Ord` *must*
515521/// agree with each other. That is, `a.cmp(b) == Ordering::Equal` if
516522/// and only if `a == b` and `Some(a.cmp(b)) == a.partial_cmp(b)` for
517523/// all `a` and `b`. It's easy to accidentally make them disagree by
@@ -548,13 +554,15 @@ impl<T: Ord> Ord for Reverse<T> {
548554/// }
549555/// }
550556/// ```
557+ ///
558+ /// [`cmp`]: Ord::cmp
551559#[ doc( alias = "<" ) ]
552560#[ doc( alias = ">" ) ]
553561#[ doc( alias = "<=" ) ]
554562#[ doc( alias = ">=" ) ]
555563#[ stable( feature = "rust1" , since = "1.0.0" ) ]
556564pub trait Ord : Eq + PartialOrd < Self > {
557- /// This method returns an `Ordering` between `self` and `other`.
565+ /// This method returns an [ `Ordering`] between `self` and `other`.
558566 ///
559567 /// By convention, `self.cmp(&other)` returns the ordering matching the expression
560568 /// `self <operator> other` if true.
@@ -689,20 +697,20 @@ impl PartialOrd for Ordering {
689697///
690698/// ## How can I implement `PartialOrd`?
691699///
692- /// `PartialOrd` only requires implementation of the `partial_cmp` method, with the others
700+ /// `PartialOrd` only requires implementation of the [ `partial_cmp`] method, with the others
693701/// generated from default implementations.
694702///
695703/// However it remains possible to implement the others separately for types which do not have a
696704/// total order. For example, for floating point numbers, `NaN < 0 == false` and `NaN >= 0 ==
697705/// false` (cf. IEEE 754-2008 section 5.11).
698706///
699- /// `PartialOrd` requires your type to be `PartialEq`.
707+ /// `PartialOrd` requires your type to be [ `PartialEq`] .
700708///
701- /// Implementations of `PartialEq`, `PartialOrd`, and `Ord` *must* agree with each other. It's
709+ /// Implementations of [ `PartialEq`] , `PartialOrd`, and [ `Ord`] *must* agree with each other. It's
702710/// easy to accidentally make them disagree by deriving some of the traits and manually
703711/// implementing others.
704712///
705- /// If your type is `Ord`, you can implement `partial_cmp()` by using `cmp()` :
713+ /// If your type is [ `Ord`] , you can implement [ `partial_cmp`] by using [ `cmp`] :
706714///
707715/// ```
708716/// use std::cmp::Ordering;
@@ -733,7 +741,7 @@ impl PartialOrd for Ordering {
733741/// }
734742/// ```
735743///
736- /// You may also find it useful to use `partial_cmp()` on your type's fields. Here
744+ /// You may also find it useful to use [ `partial_cmp`] on your type's fields. Here
737745/// is an example of `Person` types who have a floating-point `height` field that
738746/// is the only field to be used for sorting:
739747///
@@ -768,6 +776,9 @@ impl PartialOrd for Ordering {
768776/// assert_eq!(x < y, true);
769777/// assert_eq!(x.lt(&y), true);
770778/// ```
779+ ///
780+ /// [`partial_cmp`]: PartialOrd::partial_cmp
781+ /// [`cmp`]: Ord::cmp
771782#[ lang = "partial_ord" ]
772783#[ stable( feature = "rust1" , since = "1.0.0" ) ]
773784#[ doc( alias = ">" ) ]
@@ -893,7 +904,7 @@ pub macro PartialOrd($item:item) {
893904///
894905/// Returns the first argument if the comparison determines them to be equal.
895906///
896- /// Internally uses an alias to `Ord::min`.
907+ /// Internally uses an alias to [ `Ord::min`] .
897908///
898909/// # Examples
899910///
@@ -956,7 +967,7 @@ pub fn min_by_key<T, F: FnMut(&T) -> K, K: Ord>(v1: T, v2: T, mut f: F) -> T {
956967///
957968/// Returns the second argument if the comparison determines them to be equal.
958969///
959- /// Internally uses an alias to `Ord::max`.
970+ /// Internally uses an alias to [ `Ord::max`] .
960971///
961972/// # Examples
962973///
0 commit comments