We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
Ordering
library\core
1 parent ea5dc09 commit 79d563cCopy full SHA for 79d563c
library/core/tests/cmp.rs
@@ -1,4 +1,7 @@
1
-use core::cmp::{self, Ordering::*};
+use core::cmp::{
2
+ self,
3
+ Ordering::{self, *},
4
+};
5
6
#[test]
7
fn test_int_totalord() {
@@ -116,3 +119,16 @@ fn test_user_defined_eq() {
116
119
assert!(SketchyNum { num: 37 } == SketchyNum { num: 34 });
117
120
assert!(SketchyNum { num: 25 } != SketchyNum { num: 57 });
118
121
}
122
+
123
+#[test]
124
+fn ordering_const() {
125
+ // test that the methods of `Ordering` are usable in a const context
126
127
+ const ORDERING: Ordering = Greater;
128
129
+ const REVERSE: Ordering = ORDERING.reverse();
130
+ assert_eq!(REVERSE, Less);
131
132
+ const THEN: Ordering = Equal.then(ORDERING);
133
+ assert_eq!(THEN, Greater);
134
+}
src/test/ui/consts/const-ordering.rs
0 commit comments