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
333 B
Rust
Raw Normal View History

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