@@ -661,20 +661,37 @@ impl<T: Clone> Clone for Reverse<T> {
661661///
662662/// ## Derivable
663663///
664- /// This trait can be used with `#[derive]`. When `derive`d on structs, it will produce a
665- /// [lexicographic](https://en.wikipedia.org/wiki/Lexicographic_order) ordering based on the top-to-bottom declaration order of the struct's members.
666- /// When `derive`d on enums, variants are ordered by their top-to-bottom discriminant order.
667- /// This means variants at the top are less than variants at the bottom.
668- /// Here's an example:
664+ /// This trait can be used with `#[derive]`.
669665///
666+ /// When `derive`d on structs, it will produce a
667+ /// [lexicographic](https://en.wikipedia.org/wiki/Lexicographic_order) ordering
668+ /// based on the top-to-bottom declaration order of the struct's members.
669+ ///
670+ /// When `derive`d on enums, variants are ordered by their discriminants.
671+ /// By default, the discriminant is smallest for variants at the top, and
672+ /// largest for variants at the bottom. Here's an example:
673+ ///
674+ /// ```
675+ /// #[derive(PartialEq, Eq, PartialOrd, Ord)]
676+ /// enum E {
677+ /// Top,
678+ /// Bottom,
679+ /// }
680+ ///
681+ /// assert!(E::Top < E::Bottom);
682+ /// ```
683+ ///
684+ /// However, manually setting the discriminants can override this default
685+ /// behavior:
686+ ////
670687/// ```
671688/// #[derive(PartialEq, Eq, PartialOrd, Ord)]
672- /// enum Size {
673- /// Small ,
674- /// Large ,
689+ /// enum E {
690+ /// Top = 2 ,
691+ /// Bottom = 1 ,
675692/// }
676693///
677- /// assert!(Size::Small < Size::Large );
694+ /// assert!(E::Bottom < E::Top );
678695/// ```
679696///
680697/// ## Lexicographical comparison
@@ -895,20 +912,37 @@ impl PartialOrd for Ordering {
895912///
896913/// ## Derivable
897914///
898- /// This trait can be used with `#[derive]`. When `derive`d on structs, it will produce a
899- /// lexicographic ordering based on the top-to-bottom declaration order of the struct's members.
900- /// When `derive`d on enums, variants are ordered by their top-to-bottom discriminant order.
901- /// This means variants at the top are less than variants at the bottom.
902- /// Here's an example:
915+ /// This trait can be used with `#[derive]`.
916+ ///
917+ /// When `derive`d on structs, it will produce a
918+ /// [lexicographic](https://en.wikipedia.org/wiki/Lexicographic_order) ordering
919+ /// based on the top-to-bottom declaration order of the struct's members.
920+ ///
921+ /// When `derive`d on enums, variants are ordered by their discriminants.
922+ /// By default, the discriminant is smallest for variants at the top, and
923+ /// largest for variants at the bottom. Here's an example:
924+ ///
925+ /// ```
926+ /// #[derive(PartialEq, PartialOrd)]
927+ /// enum E {
928+ /// Top,
929+ /// Bottom,
930+ /// }
931+ ///
932+ /// assert!(E::Top < E::Bottom);
933+ /// ```
903934///
935+ /// However, manually setting the discriminants can override this default
936+ /// behavior:
937+ ////
904938/// ```
905939/// #[derive(PartialEq, PartialOrd)]
906- /// enum Size {
907- /// Small ,
908- /// Large ,
940+ /// enum E {
941+ /// Top = 2 ,
942+ /// Bottom = 1 ,
909943/// }
910944///
911- /// assert!(Size::Small < Size::Large );
945+ /// assert!(E::Bottom < E::Top );
912946/// ```
913947///
914948/// ## How can I implement `PartialOrd`?
0 commit comments