Skip to content

Commit ea31d86

Browse files
committed
Auto merge of rust-lang#75463 - CDirkx:ordering-const, r=CDirkx
Make some Ordering methods const Constify the following methods of `core::cmp::Ordering`: - `reverse` - `then` Possible because of rust-lang#49146 (Allow `if` and `match` in constants). Tracking issue: rust-lang#76113
2 parents 763cf9c + c7f28c6 commit ea31d86

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

core/src/cmp.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -356,8 +356,9 @@ impl Ordering {
356356
/// ```
357357
#[inline]
358358
#[must_use]
359+
#[rustc_const_stable(feature = "const_ordering", since = "1.48.0")]
359360
#[stable(feature = "rust1", since = "1.0.0")]
360-
pub fn reverse(self) -> Ordering {
361+
pub const fn reverse(self) -> Ordering {
361362
match self {
362363
Less => Greater,
363364
Equal => Equal,
@@ -394,8 +395,9 @@ impl Ordering {
394395
/// ```
395396
#[inline]
396397
#[must_use]
398+
#[rustc_const_stable(feature = "const_ordering", since = "1.48.0")]
397399
#[stable(feature = "ordering_chaining", since = "1.17.0")]
398-
pub fn then(self, other: Ordering) -> Ordering {
400+
pub const fn then(self, other: Ordering) -> Ordering {
399401
match self {
400402
Equal => other,
401403
_ => self,

0 commit comments

Comments
 (0)