Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions library/core/src/cmp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ pub struct AssertParamIsEq<T: Eq + ?Sized> {
/// let result = 2.cmp(&1);
/// assert_eq!(Ordering::Greater, result);
/// ```
#[derive(Clone, Copy, PartialEq, Debug, Hash)]
#[derive(Clone, Copy, PartialEq, Eq, Debug, Hash)]
#[stable(feature = "rust1", since = "1.0.0")]
#[repr(i8)]
pub enum Ordering {
Expand Down Expand Up @@ -861,9 +861,6 @@ pub macro Ord($item:item) {
/* compiler built-in */
}

#[stable(feature = "rust1", since = "1.0.0")]
impl Eq for Ordering {}

#[stable(feature = "rust1", since = "1.0.0")]
impl Ord for Ordering {
#[inline]
Expand Down
13 changes: 13 additions & 0 deletions library/core/tests/cmp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,19 @@ fn ordering_const() {
assert_eq!(THEN, Greater);
}

#[test]
fn ordering_structural_eq() {
// test that consts of type `Ordering` are usable in patterns

const ORDERING: Ordering = Greater;

const REVERSE: Ordering = ORDERING.reverse();
match Ordering::Less {
REVERSE => {}
_ => unreachable!(),
};
}

#[test]
fn cmp_default() {
// Test default methods in PartialOrd and PartialEq
Expand Down