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.
2 parents 49b6ac0 + 51c4299 commit dbf9cc1Copy full SHA for dbf9cc1
library/coretests/tests/cmp.rs
@@ -48,6 +48,37 @@ fn test_ord_min_max_by() {
48
assert_eq!(cmp::max_by(2, -1, f), 2);
49
}
50
51
+// Regression test for #136307 / #139357: ensure compare() receives (v1, v2), not (v2, v1).
52
+#[test]
53
+fn min_by_compare_argument_order() {
54
+ let mut order = vec![];
55
+ let _ = cmp::min_by(1i32, 2, |a, b| {
56
+ order.push((*a, *b));
57
+ a.cmp(b)
58
+ });
59
+ assert_eq!(order, [(1, 2)]);
60
+}
61
+
62
63
+fn max_by_compare_argument_order() {
64
65
+ let _ = cmp::max_by(1i32, 2, |a, b| {
66
67
68
69
70
71
72
73
+fn minmax_by_compare_argument_order() {
74
75
+ let _ = cmp::minmax_by(1i32, 2, |a, b| {
76
77
78
79
80
81
82
#[test]
83
fn test_ord_min_max_by_key() {
84
let f = |x: &i32| x.abs();
library/coretests/tests/lib.rs
@@ -14,6 +14,7 @@
14
#![feature(char_internals)]
15
#![feature(char_max_len)]
16
#![feature(clone_to_uninit)]
17
+#![feature(cmp_minmax)]
18
#![feature(const_array)]
19
#![feature(const_bool)]
20
#![feature(const_cell_traits)]
0 commit comments