diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2022-09-15 08:00:16 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-09-15 08:00:16 +0200 |
| commit | b71b640f3c36721fde44e9add8e463f2973356e0 (patch) | |
| tree | 4f9ce0aeef86a98c700e2a787d346bc3014b0332 | |
| parent | a88b96b81ba4f7e77727440999e5f26b967cc757 (diff) | |
| parent | f4ff6860dcefbe59fac837f7208a83b5f83b2820 (diff) | |
| download | rust-b71b640f3c36721fde44e9add8e463f2973356e0.tar.gz rust-b71b640f3c36721fde44e9add8e463f2973356e0.zip | |
Rollup merge of #101810 - raldone01:feat/const_partial_eq_ordering, r=fee1-dead
Constify `PartialEq` for `Ordering`
Adds `impl const PartialEq for Ordering {}` to #92391.
| -rw-r--r-- | library/core/src/cmp.rs | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/library/core/src/cmp.rs b/library/core/src/cmp.rs index 8a30bb67450..d9f2d3d64d6 100644 --- a/library/core/src/cmp.rs +++ b/library/core/src/cmp.rs @@ -23,6 +23,7 @@ #![stable(feature = "rust1", since = "1.0.0")] use crate::marker::Destruct; +use crate::marker::StructuralPartialEq; use self::Ordering::*; @@ -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 { @@ -885,6 +886,18 @@ pub macro Ord($item:item) { } #[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 { #[inline] |
