Skip to content

Commit b13b495

Browse files
committed
Add test for StructuralEq for std::cmp::Ordering.
Added test in library/core/tests/cmp.rs that ensures that `const`s of type `Ordering`s can be used in patterns.
1 parent ba611d5 commit b13b495

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

library/core/tests/cmp.rs

+13
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,19 @@ fn ordering_const() {
133133
assert_eq!(THEN, Greater);
134134
}
135135

136+
#[test]
137+
fn ordering_structural_eq() {
138+
// test that consts of type `Ordering` are usable in patterns
139+
140+
const ORDERING: Ordering = Greater;
141+
142+
const REVERSE: Ordering = ORDERING.reverse();
143+
match Ordering::Less {
144+
REVERSE => {}
145+
_ => unreachable!(),
146+
};
147+
}
148+
136149
#[test]
137150
fn cmp_default() {
138151
// Test default methods in PartialOrd and PartialEq

0 commit comments

Comments
 (0)