@@ -15,45 +15,51 @@ use super::DeterministicRng;
15
15
16
16
#[ test]
17
17
fn test_clone_eq ( ) {
18
- let mut m = BTreeSet :: new ( ) ;
18
+ let mut m = BTreeSet :: new ( ) ;
19
19
20
- m. insert ( 1 ) ;
21
- m. insert ( 2 ) ;
20
+ m. insert ( 1 ) ;
21
+ m. insert ( 2 ) ;
22
22
23
- assert ! ( m. clone( ) == m) ;
23
+ assert ! ( m. clone( ) == m) ;
24
24
}
25
25
26
26
#[ test]
27
27
fn test_hash ( ) {
28
- let mut x = BTreeSet :: new ( ) ;
29
- let mut y = BTreeSet :: new ( ) ;
28
+ let mut x = BTreeSet :: new ( ) ;
29
+ let mut y = BTreeSet :: new ( ) ;
30
30
31
- x. insert ( 1 ) ;
32
- x. insert ( 2 ) ;
33
- x. insert ( 3 ) ;
31
+ x. insert ( 1 ) ;
32
+ x. insert ( 2 ) ;
33
+ x. insert ( 3 ) ;
34
34
35
- y. insert ( 3 ) ;
36
- y. insert ( 2 ) ;
37
- y. insert ( 1 ) ;
35
+ y. insert ( 3 ) ;
36
+ y. insert ( 2 ) ;
37
+ y. insert ( 1 ) ;
38
38
39
- assert ! ( :: hash( & x) == :: hash( & y) ) ;
39
+ assert ! ( :: hash( & x) == :: hash( & y) ) ;
40
40
}
41
41
42
- fn check < F > ( a : & [ i32 ] , b : & [ i32 ] , expected : & [ i32 ] , f : F ) where
43
- F : FnOnce ( & BTreeSet < i32 > , & BTreeSet < i32 > , & mut FnMut ( & i32 ) -> bool ) -> bool ,
42
+ fn check < F > ( a : & [ i32 ] , b : & [ i32 ] , expected : & [ i32 ] , f : F )
43
+ where F : FnOnce ( & BTreeSet < i32 > , & BTreeSet < i32 > , & mut FnMut ( & i32 ) -> bool ) -> bool
44
44
{
45
45
let mut set_a = BTreeSet :: new ( ) ;
46
46
let mut set_b = BTreeSet :: new ( ) ;
47
47
48
- for x in a { assert ! ( set_a. insert( * x) ) }
49
- for y in b { assert ! ( set_b. insert( * y) ) }
48
+ for x in a {
49
+ assert ! ( set_a. insert( * x) )
50
+ }
51
+ for y in b {
52
+ assert ! ( set_b. insert( * y) )
53
+ }
50
54
51
55
let mut i = 0 ;
52
- f ( & set_a, & set_b, & mut |& x| {
53
- assert_eq ! ( x, expected[ i] ) ;
54
- i += 1 ;
55
- true
56
- } ) ;
56
+ f ( & set_a,
57
+ & set_b,
58
+ & mut |& x| {
59
+ assert_eq ! ( x, expected[ i] ) ;
60
+ i += 1 ;
61
+ true
62
+ } ) ;
57
63
assert_eq ! ( i, expected. len( ) ) ;
58
64
}
59
65
@@ -82,9 +88,7 @@ fn test_difference() {
82
88
check_difference ( & [ ] , & [ ] , & [ ] ) ;
83
89
check_difference ( & [ 1 , 12 ] , & [ ] , & [ 1 , 12 ] ) ;
84
90
check_difference ( & [ ] , & [ 1 , 2 , 3 , 9 ] , & [ ] ) ;
85
- check_difference ( & [ 1 , 3 , 5 , 9 , 11 ] ,
86
- & [ 3 , 9 ] ,
87
- & [ 1 , 5 , 11 ] ) ;
91
+ check_difference ( & [ 1 , 3 , 5 , 9 , 11 ] , & [ 3 , 9 ] , & [ 1 , 5 , 11 ] ) ;
88
92
check_difference ( & [ -5 , 11 , 22 , 33 , 40 , 42 ] ,
89
93
& [ -12 , -5 , 14 , 23 , 34 , 38 , 39 , 50 ] ,
90
94
& [ 11 , 22 , 33 , 40 , 42 ] ) ;
@@ -245,10 +249,18 @@ fn test_recovery() {
245
249
fn test_variance ( ) {
246
250
use std:: collections:: btree_set:: { IntoIter , Iter , Range } ;
247
251
248
- fn set < ' new > ( v : BTreeSet < & ' static str > ) -> BTreeSet < & ' new str > { v }
249
- fn iter < ' a , ' new > ( v : Iter < ' a , & ' static str > ) -> Iter < ' a , & ' new str > { v }
250
- fn into_iter < ' new > ( v : IntoIter < & ' static str > ) -> IntoIter < & ' new str > { v }
251
- fn range < ' a , ' new > ( v : Range < ' a , & ' static str > ) -> Range < ' a , & ' new str > { v }
252
+ fn set < ' new > ( v : BTreeSet < & ' static str > ) -> BTreeSet < & ' new str > {
253
+ v
254
+ }
255
+ fn iter < ' a , ' new > ( v : Iter < ' a , & ' static str > ) -> Iter < ' a , & ' new str > {
256
+ v
257
+ }
258
+ fn into_iter < ' new > ( v : IntoIter < & ' static str > ) -> IntoIter < & ' new str > {
259
+ v
260
+ }
261
+ fn range < ' a , ' new > ( v : Range < ' a , & ' static str > ) -> Range < ' a , & ' new str > {
262
+ v
263
+ }
252
264
}
253
265
254
266
#[ test]
@@ -277,9 +289,7 @@ fn test_append() {
277
289
278
290
fn rand_data ( len : usize ) -> Vec < u32 > {
279
291
let mut rng = DeterministicRng :: new ( ) ;
280
- Vec :: from_iter (
281
- ( 0 ..len) . map ( |_| rng. next ( ) )
282
- )
292
+ Vec :: from_iter ( ( 0 ..len) . map ( |_| rng. next ( ) ) )
283
293
}
284
294
285
295
#[ test]
0 commit comments