Skip to content

Commit

Permalink
Rollup merge of rust-lang#101810 - raldone01:feat/const_partial_eq_or…
Browse files Browse the repository at this point in the history
…dering, r=fee1-dead

Constify `PartialEq` for `Ordering`

Adds `impl const PartialEq for Ordering {}` to rust-lang#92391.
  • Loading branch information
matthiaskrgr authored Sep 15, 2022
2 parents a88b96b + f4ff686 commit b71b640
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion library/core/src/cmp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#![stable(feature = "rust1", since = "1.0.0")]

use crate::marker::Destruct;
use crate::marker::StructuralPartialEq;

use self::Ordering::*;

Expand Down Expand Up @@ -338,7 +339,7 @@ pub struct AssertParamIsEq<T: Eq + ?Sized> {
/// let result = 2.cmp(&1);
/// assert_eq!(Ordering::Greater, result);
/// ```
#[derive(Clone, Copy, PartialEq, Eq, Debug, Hash)]
#[derive(Clone, Copy, Eq, Debug, Hash)]
#[stable(feature = "rust1", since = "1.0.0")]
#[repr(i8)]
pub enum Ordering {
Expand Down Expand Up @@ -884,6 +885,18 @@ pub macro Ord($item:item) {
/* compiler built-in */
}

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

#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_cmp", issue = "92391")]
impl const PartialEq for Ordering {
#[inline]
fn eq(&self, other: &Self) -> bool {
(*self as i32).eq(&(*other as i32))
}
}

#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_cmp", issue = "92391")]
impl const Ord for Ordering {
Expand Down

0 comments on commit b71b640

Please sign in to comment.