-
Notifications
You must be signed in to change notification settings - Fork 12.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Constify the following methods of `core::cmp::Ordering`: - `reverse` - `then` Stabilizes these methods as const under the `const_ordering` feature. Also adds a test for these methods in a const context. Possible because of #49146 (Allow `if` and `match` in constants).
- Loading branch information
CDirkx
committed
Sep 1, 2020
1 parent
e88e908
commit ea5dc09
Showing
2 changed files
with
19 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// run-pass | ||
|
||
use std::cmp::Ordering; | ||
|
||
// the following methods of core::cmp::Ordering are const: | ||
// - reverse | ||
// - then | ||
|
||
fn main() { | ||
const REVERSE : Ordering = Ordering::Greater.reverse(); | ||
assert_eq!(REVERSE, Ordering::Less); | ||
|
||
const THEN : Ordering = Ordering::Equal.then(REVERSE); | ||
assert_eq!(THEN, Ordering::Less); | ||
} |