Skip to content

Commit

Permalink
Make some Ordering methods const
Browse files Browse the repository at this point in the history
Constify the following methods of `core::cmp::Ordering`:
 - `reverse`
 - `then`

Possible because of rust-lang#49146 (Allow `if` and `match` in constants).
  • Loading branch information
CDirkx committed Aug 12, 2020
1 parent 3df25ae commit 6b0d44e
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions library/core/src/cmp.rs
Expand Up @@ -357,7 +357,7 @@ impl Ordering {
#[inline]
#[must_use]
#[stable(feature = "rust1", since = "1.0.0")]
pub fn reverse(self) -> Ordering {
pub const fn reverse(self) -> Ordering {
match self {
Less => Greater,
Equal => Equal,
Expand Down Expand Up @@ -395,7 +395,7 @@ impl Ordering {
#[inline]
#[must_use]
#[stable(feature = "ordering_chaining", since = "1.17.0")]
pub fn then(self, other: Ordering) -> Ordering {
pub const fn then(self, other: Ordering) -> Ordering {
match self {
Equal => other,
_ => self,
Expand Down

0 comments on commit 6b0d44e

Please sign in to comment.