10
10
11
11
// ignore-pretty very bad with line comments
12
12
13
+ #![ feature( unboxed_closures) ]
14
+
13
15
extern crate collections;
14
16
extern crate rand;
15
17
@@ -31,7 +33,7 @@ struct Results {
31
33
delete_strings : Duration ,
32
34
}
33
35
34
- fn timed ( result : & mut Duration , op: || ) {
36
+ fn timed < F > ( result : & mut Duration , op : F ) where F : FnOnce ( ) {
35
37
* result = Duration :: span ( op) ;
36
38
}
37
39
@@ -66,7 +68,7 @@ impl Results {
66
68
rand_cap : uint ,
67
69
f: || -> T ) { {
68
70
let mut set = f ( ) ;
69
- timed ( & mut self . sequential_ints , || {
71
+ timed ( & mut self . sequential_ints , move || {
70
72
for i in range ( 0 u, num_keys) {
71
73
set. insert ( i) ;
72
74
}
@@ -79,7 +81,7 @@ impl Results {
79
81
80
82
{
81
83
let mut set = f ( ) ;
82
- timed ( & mut self . random_ints , || {
84
+ timed ( & mut self . random_ints , move || {
83
85
for _ in range ( 0 , num_keys) {
84
86
set. insert ( rng. gen :: < uint > ( ) % rand_cap) ;
85
87
}
@@ -92,7 +94,7 @@ impl Results {
92
94
set. insert ( i) ;
93
95
}
94
96
95
- timed ( & mut self . delete_ints , || {
97
+ timed ( & mut self . delete_ints , move || {
96
98
for i in range ( 0 u, num_keys) {
97
99
assert ! ( set. remove( & i) ) ;
98
100
}
@@ -108,7 +110,7 @@ impl Results {
108
110
f: || -> T ) {
109
111
{
110
112
let mut set = f ( ) ;
111
- timed ( & mut self . sequential_strings , || {
113
+ timed ( & mut self . sequential_strings , move || {
112
114
for i in range ( 0 u, num_keys) {
113
115
set. insert ( i. to_string ( ) ) ;
114
116
}
@@ -121,7 +123,7 @@ impl Results {
121
123
122
124
{
123
125
let mut set = f ( ) ;
124
- timed ( & mut self . random_strings , || {
126
+ timed ( & mut self . random_strings , move || {
125
127
for _ in range ( 0 , num_keys) {
126
128
let s = rng. gen :: < uint > ( ) . to_string ( ) ;
127
129
set. insert ( s) ;
@@ -134,7 +136,7 @@ impl Results {
134
136
for i in range ( 0 u, num_keys) {
135
137
set. insert ( i. to_string ( ) ) ;
136
138
}
137
- timed ( & mut self . delete_strings , || {
139
+ timed ( & mut self . delete_strings , move || {
138
140
for i in range ( 0 u, num_keys) {
139
141
assert ! ( set. remove( & i. to_string( ) ) ) ;
140
142
}
0 commit comments