@@ -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-
6342fn 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
0 commit comments