File tree 3 files changed +20
-0
lines changed
3 files changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -356,6 +356,7 @@ impl Ordering {
356
356
/// ```
357
357
#[ inline]
358
358
#[ must_use]
359
+ #[ rustc_const_unstable( feature = "const_ordering" , issue = "76113" ) ]
359
360
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
360
361
pub const fn reverse ( self ) -> Ordering {
361
362
match self {
@@ -394,6 +395,7 @@ impl Ordering {
394
395
/// ```
395
396
#[ inline]
396
397
#[ must_use]
398
+ #[ rustc_const_unstable( feature = "const_ordering" , issue = "76113" ) ]
397
399
#[ stable( feature = "ordering_chaining" , since = "1.17.0" ) ]
398
400
pub const fn then ( self , other : Ordering ) -> Ordering {
399
401
match self {
Original file line number Diff line number Diff line change 86
86
#![ feature( const_ptr_offset_from) ]
87
87
#![ feature( const_raw_ptr_comparison) ]
88
88
#![ feature( const_result) ]
89
+ #![ feature( const_ordering) ]
89
90
#![ feature( const_slice_from_raw_parts) ]
90
91
#![ feature( const_slice_ptr_len) ]
91
92
#![ feature( const_size_of_val) ]
Original file line number Diff line number Diff line change
1
+ // run-pass
2
+
3
+ #![ feature( const_ordering) ]
4
+
5
+ use std:: cmp:: Ordering ;
6
+
7
+ // the following methods of core::cmp::Ordering are const:
8
+ // - reverse
9
+ // - then
10
+
11
+ fn main ( ) {
12
+ const REVERSE : Ordering = Ordering :: Greater . reverse ( ) ;
13
+ assert_eq ! ( REVERSE , Ordering :: Less ) ;
14
+
15
+ const THEN : Ordering = Ordering :: Equal . then ( REVERSE ) ;
16
+ assert_eq ! ( THEN , Ordering :: Less ) ;
17
+ }
You can’t perform that action at this time.
0 commit comments