mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-27 01:04:03 +00:00
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).
This commit is contained in:
parent
3df25ae186
commit
6b0d44e92a
@ -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,
|
||||
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user