blob: e90c1ee815aaea4fee81fd4032ba1d01e1fb12da (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
// run-pass
fn iter_vec<T, F>(v: Vec<T>, mut f: F) where F: FnMut(&T) { for x in &v { f(x); } }
pub fn main() {
let v = vec![1, 2, 3, 4, 5];
let mut sum = 0;
iter_vec(v.clone(), |i| {
iter_vec(v.clone(), |j| {
sum += *i * *j;
});
});
println!("{}", sum);
assert_eq!(sum, 225);
}
|