os-rust/tests/ui/closures/old-closure-iter-2.rs

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

16 lines
334 B
Rust
Raw Normal View History

//@ run-pass
2015-01-31 12:20:46 -05: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 16:57:27 -07:00
pub fn main() {
let v = vec![1, 2, 3, 4, 5];
let mut sum = 0;
2013-03-15 18:27:15 -04:00
iter_vec(v.clone(), |i| {
iter_vec(v.clone(), |j| {
2013-02-21 19:10:33 -08:00
sum += *i * *j;
});
});
2014-10-14 21:07:11 -04:00
println!("{}", sum);
assert_eq!(sum, 225);
2011-08-15 15:34:47 -07:00
}