2011-06-15 13:19:50 -05:00
|
|
|
|
|
|
|
|
2012-01-23 16:59:00 -06:00
|
|
|
fn pairs(it: fn((int, int))) {
|
2012-03-22 10:39:41 -05:00
|
|
|
let mut i: int = 0;
|
|
|
|
let mut j: int = 0;
|
2011-10-21 06:14:28 -05:00
|
|
|
while i < 10 { it((i, j)); i += 1; j += i; }
|
2010-06-23 23:03:09 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
2012-03-22 10:39:41 -05:00
|
|
|
let mut i: int = 10;
|
|
|
|
let mut j: int = 0;
|
2012-06-30 18:19:07 -05:00
|
|
|
do pairs() |p| {
|
2011-10-21 06:14:28 -05:00
|
|
|
let (_0, _1) = p;
|
2011-12-22 19:53:53 -06:00
|
|
|
log(debug, _0);
|
|
|
|
log(debug, _1);
|
2011-10-21 06:14:28 -05:00
|
|
|
assert (_0 + 10 == i);
|
2011-06-15 13:19:50 -05:00
|
|
|
i += 1;
|
2011-10-21 06:14:28 -05:00
|
|
|
j = _1;
|
|
|
|
};
|
2011-06-15 13:19:50 -05:00
|
|
|
assert (j == 45);
|
2011-08-15 23:54:52 -05:00
|
|
|
}
|