@@ -39,30 +39,8 @@ fn test_hash() {
39
39
assert ! ( :: hash( & x) == :: hash( & y) ) ;
40
40
}
41
41
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
-
63
42
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 ,
66
44
{
67
45
let mut set_a = BTreeSet :: new ( ) ;
68
46
let mut set_b = BTreeSet :: new ( ) ;
@@ -71,7 +49,11 @@ fn check<F>(a: &[i32], b: &[i32], expected: &[i32], f: F) where
71
49
for y in b { assert ! ( set_b. insert( * y) ) }
72
50
73
51
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
+ } ) ;
75
57
assert_eq ! ( i, expected. len( ) ) ;
76
58
}
77
59
0 commit comments