Skip to content

Commit 6b0d44e

Browse files
author
CDirkx
committed
Make some Ordering methods const
Constify the following methods of `core::cmp::Ordering`: - `reverse` - `then` Possible because of #49146 (Allow `if` and `match` in constants).
1 parent 3df25ae commit 6b0d44e

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

library/core/src/cmp.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,7 @@ impl Ordering {
357357
#[inline]
358358
#[must_use]
359359
#[stable(feature = "rust1", since = "1.0.0")]
360-
pub fn reverse(self) -> Ordering {
360+
pub const fn reverse(self) -> Ordering {
361361
match self {
362362
Less => Greater,
363363
Equal => Equal,
@@ -395,7 +395,7 @@ impl Ordering {
395395
#[inline]
396396
#[must_use]
397397
#[stable(feature = "ordering_chaining", since = "1.17.0")]
398-
pub fn then(self, other: Ordering) -> Ordering {
398+
pub const fn then(self, other: Ordering) -> Ordering {
399399
match self {
400400
Equal => other,
401401
_ => self,

0 commit comments

Comments
 (0)