mirror of
https://github.com/rust-lang/rust.git
synced 2024-10-31 06:22:00 +00:00
Copy an example to PartialOrd as well
This commit is contained in:
parent
69d25fc582
commit
8f33b4eed1
@ -668,7 +668,7 @@ impl<T: Clone> Clone for Reverse<T> {
|
||||
/// Here's an example:
|
||||
///
|
||||
/// ```
|
||||
/// #[derive(PartialEq, PartialOrd)]
|
||||
/// #[derive(PartialEq, Eq, PartialOrd, Ord)]
|
||||
/// enum Size {
|
||||
/// Small,
|
||||
/// Large,
|
||||
@ -898,6 +898,18 @@ impl PartialOrd for 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 @@ impl PartialOrd for 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);
|
||||
|
Loading…
Reference in New Issue
Block a user