summaryrefslogtreecommitdiffstats
path: root/src/test/ui/for-loop-while/foreach-simple-outer-slot.rs
blob: a8d42a789ba77aae065b5107cf26dfab0da95752 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
// run-pass



pub fn main() {
    let mut sum: isize = 0;
    first_ten(|i| { println!("main"); println!("{}", i); sum = sum + i; });
    println!("sum");
    println!("{}", sum);
    assert_eq!(sum, 45);
}

fn first_ten<F>(mut it: F) where F: FnMut(isize) {
    let mut i: isize = 0;
    while i < 10 { println!("first_ten"); it(i); i = i + 1; }
}