Skip to content

Commit 5005ed3

Browse files
author
Nick Desaulniers
committed
use iterators
1 parent 70d7de8 commit 5005ed3

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

src/test/bench/graph500-bfs.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -148,27 +148,27 @@ mod par {
148148
xs: &[A],
149149
fn_factory: &fn() -> ~fn(uint, &A) -> bool) -> bool
150150
{
151-
do vec::all(map_slices(xs, || {
151+
let mapped = map_slices(xs, || {
152152
let f = fn_factory();
153153
let result: ~fn(uint, &[A]) -> bool = |base, slice| {
154-
vec::alli(slice, |i, x| {
155-
f(i + base, x)
156-
})
154+
slice.iter().enumerate().all(|(i, x)| f(i + base, x))
157155
};
158156
result
159-
})) |x| { *x }
157+
});
158+
mapped.iter().all(|&x| x)
160159
}
161160

162161
/// Returns true if the function holds for any elements in the vector.
163162
pub fn any<A:Copy + Owned>(
164163
xs: &[A],
165164
fn_factory: &fn() -> ~fn(&A) -> bool) -> bool {
166-
do vec::any(map_slices(xs, || {
165+
let mapped = map_slices(xs, || {
167166
let f = fn_factory();
168167
let result: ~fn(uint, &[A]) -> bool =
169-
|_, slice| vec::any(slice, |x| f(x));
168+
|_, slice| slice.iter().any(f);
170169
result
171-
})) |x| { *x }
170+
});
171+
mapped.iter().any(|&x| x)
172172
}
173173
}
174174

0 commit comments

Comments
 (0)