]> git.lizzy.rs Git - rust.git/commitdiff
Copy an example to PartialOrd as well
authorAriel Davis <ariel.z.davis@icloud.com>
Sun, 16 Jan 2022 00:25:09 +0000 (16:25 -0800)
committerAriel Davis <ariel.z.davis@icloud.com>
Sun, 16 Jan 2022 00:25:09 +0000 (16:25 -0800)
library/core/src/cmp.rs

index deed9901cc9e4595919ba893927d7c34820616a8..ef81e8736ed4745f661c5bc560ca9c58a3569152 100644 (file)
@@ -668,7 +668,7 @@ fn clone_from(&mut self, other: &Self) {
 /// Here's an example:
 ///
 /// ```
-/// #[derive(PartialEq, PartialOrd)]
+/// #[derive(PartialEq, Eq, PartialOrd, Ord)]
 /// enum Size {
 ///     Small,
 ///     Large,
@@ -898,6 +898,18 @@ fn partial_cmp(&self, other: &Ordering) -> Option<Ordering> {
 /// This trait can be used with `#[derive]`. When `derive`d on structs, it will produce a
 /// lexicographic ordering based on the top-to-bottom declaration order of the struct's members.
 /// When `derive`d on enums, variants are ordered by their top-to-bottom discriminant order.
+/// This means variants at the top are less than variants at the bottom.
+/// Here's an example:
+///
+/// ```
+/// #[derive(PartialEq, PartialOrd)]
+/// enum Size {
+///     Small,
+///     Large,
+/// }
+///
+/// assert!(Size::Small < Size::Large);
+/// ```
 ///
 /// ## How can I implement `PartialOrd`?
 ///
@@ -970,8 +982,8 @@ fn partial_cmp(&self, other: &Ordering) -> Option<Ordering> {
 /// # Examples
 ///
 /// ```
-/// let x : u32 = 0;
-/// let y : u32 = 1;
+/// let x: u32 = 0;
+/// let y: u32 = 1;
 ///
 /// assert_eq!(x < y, true);
 /// assert_eq!(x.lt(&y), true);