Skip to content

Commit ef9786c

Browse files
authored
Auto merge of rust-lang#36084 - apasel422:counter, r=bluss
Address FIXME in libcollectionstest/btree/set.rs
2 parents 689c6c4 + ef4952e commit ef9786c

File tree

2 files changed

+6
-25
lines changed

2 files changed

+6
-25
lines changed

src/libcollectionstest/btree/set.rs

+6-24
Original file line numberDiff line numberDiff line change
@@ -39,30 +39,8 @@ fn test_hash() {
3939
assert!(::hash(&x) == ::hash(&y));
4040
}
4141

42-
struct Counter<'a, 'b> {
43-
i: &'a mut usize,
44-
expected: &'b [i32],
45-
}
46-
47-
impl<'a, 'b, 'c> FnMut<(&'c i32,)> for Counter<'a, 'b> {
48-
extern "rust-call" fn call_mut(&mut self, (&x,): (&'c i32,)) -> bool {
49-
assert_eq!(x, self.expected[*self.i]);
50-
*self.i += 1;
51-
true
52-
}
53-
}
54-
55-
impl<'a, 'b, 'c> FnOnce<(&'c i32,)> for Counter<'a, 'b> {
56-
type Output = bool;
57-
58-
extern "rust-call" fn call_once(mut self, args: (&'c i32,)) -> bool {
59-
self.call_mut(args)
60-
}
61-
}
62-
6342
fn check<F>(a: &[i32], b: &[i32], expected: &[i32], f: F) where
64-
// FIXME Replace Counter with `Box<FnMut(_) -> _>`
65-
F: FnOnce(&BTreeSet<i32>, &BTreeSet<i32>, Counter) -> bool,
43+
F: FnOnce(&BTreeSet<i32>, &BTreeSet<i32>, &mut FnMut(&i32) -> bool) -> bool,
6644
{
6745
let mut set_a = BTreeSet::new();
6846
let mut set_b = BTreeSet::new();
@@ -71,7 +49,11 @@ fn check<F>(a: &[i32], b: &[i32], expected: &[i32], f: F) where
7149
for y in b { assert!(set_b.insert(*y)) }
7250

7351
let mut i = 0;
74-
f(&set_a, &set_b, Counter { i: &mut i, expected: expected });
52+
f(&set_a, &set_b, &mut |&x| {
53+
assert_eq!(x, expected[i]);
54+
i += 1;
55+
true
56+
});
7557
assert_eq!(i, expected.len());
7658
}
7759

src/libcollectionstest/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
#![feature(collections)]
1717
#![feature(collections_bound)]
1818
#![feature(const_fn)]
19-
#![feature(fn_traits)]
2019
#![feature(enumset)]
2120
#![feature(pattern)]
2221
#![feature(rand)]

0 commit comments

Comments
 (0)