rust/tests/ui/closures/old-closure-iter-1.rs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

16 lines
317 B
Rust
Raw Normal View History

// run-pass
2015-01-31 17:20:46 +00:00
fn iter_vec<T, F>(v: Vec<T> , mut f: F) where F: FnMut(&T) { for x in &v { f(x); } }
2011-07-25 23:57:27 +00:00
pub fn main() {
let v = vec![1, 2, 3, 4, 5, 6, 7];
let mut odds = 0;
2012-06-30 23:19:07 +00:00
iter_vec(v, |i| {
2013-02-22 03:10:33 +00:00
if *i % 2 == 1 {
odds += 1;
}
});
2014-10-15 01:07:11 +00:00
println!("{}", odds);
assert_eq!(odds, 4);
2011-08-15 22:34:47 +00:00
}