Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
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).
  • Loading branch information
CDirkx committed Aug 12, 2020
commit 6b0d44e92a529962792d3a5f1e7b44b6e3c6ed05
4 changes: 2 additions & 2 deletions library/core/src/cmp.rs
Original file line number Diff line number Diff line change
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