// -*- rust -*- iter two() -> int { put 0; put 1; } fn main() { let vec[int] a = vec(-1, -1, -1, -1); let int p = 0; for each (int i in two()) { for each (int j in two()) { a.(p) = 10 * i + j; p += 1; } } check (a.(0) == 0); check (a.(1) == 1); check (a.(2) == 10); check (a.(3) == 11); } // -*- rust -*- iter two() -> int { put 0; put 1; } fn main() { let vec[mutable int] a = vec[mutable](-1, -1, -1, -1); let int p = 0; for each (int i in two()) { for each (int j in two()) { a.(p) = 10 * i + j; p += 1; } } check (a.(0) == 0); check (a.(1) == 1); check (a.(2) == 10); check (a.(3) == 11); } // -*- rust -*- iter two() -> int { put 0; put 1; } impure fn main() { let vec[mutable int] a = vec[mutable](-1, -1, -1, -1); let int p = 0; for each (int i in two()) { for each (int j in two()) { a.(p) = 10 * i + j; p += 1; } } check (a.(0) == 0); check (a.(1) == 1); check (a.(2) == 10); check (a.(3) == 11); } // -*- rust -*- iter two() -> int { put 0; put 1; } impure fn main() { let vec[mutable int] a = vec(mutable -1, -1, -1, -1); let int p = 0; for each (int i in two()) { for each (int j in two()) { a.(p) = 10 * i + j; p += 1; } } check (a.(0) == 0); check (a.(1) == 1); check (a.(2) == 10); check (a.(3) == 11); } // -*- rust -*- iter two() -> int { put 0; put 1; } fn main() { let vec[mutable int] a = vec(mutable -1, -1, -1, -1); let int p = 0; for each (int i in two()) { for each (int j in two()) { a.(p) = 10 * i + j; p += 1; } } check (a.(0) == 0); check (a.(1) == 1); check (a.(2) == 10); check (a.(3) == 11); } // -*- rust -*- iter two() -> int { put 0; put 1; } fn main() { let vec[mutable int] a = vec(mutable -1, -1, -1, -1); let int p = 0; for each (int i in two()) { for each (int j in two()) { a.(p) = 10 * i + j; p += 1; } } assert (a.(0) == 0); assert (a.(1) == 1); assert (a.(2) == 10); assert (a.(3) == 11); } // -*- rust -*- iter two() -> int { put 0; put 1; } fn main() { let vec[mutable int] a = vec(mutable -1, -1, -1, -1); let int p = 0; for each (int i in two()) { for each (int j in two()) { a.(p) = 10 * i + j; p += 1; } } check (a.(0) == 0); check (a.(1) == 1); check (a.(2) == 10); check (a.(3) == 11); } // -*- rust -*- iter two() -> int { put 0; put 1; } fn main() { let vec[mutable int] a = vec(mutable -1, -1, -1, -1); let int p = 0; for each (int i in two()) { for each (int j in two()) { a.(p) = 10 * i + j; p += 1; } } assert (a.(0) == 0); assert (a.(1) == 1); assert (a.(2) == 10); assert (a.(3) == 11); } // -*- rust -*- iter two() -> int { put 0; put 1; } fn main() { let vec[mutable int] a = [mutable -1, -1, -1, -1]; let int p = 0; for each (int i in two()) { for each (int j in two()) { a.(p) = 10 * i + j; p += 1; } } assert (a.(0) == 0); assert (a.(1) == 1); assert (a.(2) == 10); assert (a.(3) == 11); } // -*- rust -*- iter two() -> int { put 0; put 1; } fn main() { let vec[mutable int] a = [mutable -1, -1, -1, -1]; let int p = 0; for each (int i in two()) { for each (int j in two()) { a.(p) = 10 * i + j; p += 1; } } assert (a.(0) == 0); assert (a.(1) == 1); assert (a.(2) == 10); assert (a.(3) == 11); } // -*- rust -*- iter two() -> int { put 0; put 1; } fn main() { let a: vec[mutable int] = [mutable -1, -1, -1, -1]; let p: int = 0; for each i: int in two() { for each j: int in two() { a.(p) = 10 * i + j; p += 1; } } assert (a.(0) == 0); assert (a.(1) == 1); assert (a.(2) == 10); assert (a.(3) == 11); } // -*- rust -*- iter two() -> int { put 0; put 1; } fn main() { let a: [mutable int] = ~[mutable -1, -1, -1, -1]; let p: int = 0; for each i: int in two() { for each j: int in two() { a.(p) = 10 * i + j; p += 1; } } assert (a.(0) == 0); assert (a.(1) == 1); assert (a.(2) == 10); assert (a.(3) == 11); } // -*- rust -*- iter two() -> int { put 0; put 1; } fn main() { let a: [mutable int] = ~[mutable -1, -1, -1, -1]; let p: int = 0; for each i: int in two() { for each j: int in two() { a.(p) = 10 * i + j; p += 1; } } assert (a.(0) == 0); assert (a.(1) == 1); assert (a.(2) == 10); assert (a.(3) == 11); } // -*- rust -*- iter two() -> int { put 0; put 1; } fn main() { let a: [mutable int] = [mutable -1, -1, -1, -1]; let p: int = 0; for each i: int in two() { for each j: int in two() { a[p] = 10 * i + j; p += 1; } } assert (a[0] == 0); assert (a[1] == 1); assert (a[2] == 10); assert (a[3] == 11); } // -*- rust -*- fn two(it: block(int)) { it(0); it(1); } fn main() { let a: [mutable int] = [mutable -1, -1, -1, -1]; let p: int = 0; two {|i| two {|j| a[p] = 10 * i + j; p += 1; }; }; assert (a[0] == 0); assert (a[1] == 1); assert (a[2] == 10); assert (a[3] == 11); } // -*- rust -*- fn two(it: fn(int)) { it(0); it(1); } fn main() { let a: [mutable int] = [mutable -1, -1, -1, -1]; let p: int = 0; two {|i| two {|j| a[p] = 10 * i + j; p += 1; }; }; assert (a[0] == 0); assert (a[1] == 1); assert (a[2] == 10); assert (a[3] == 11); } // -*- rust -*- fn two(it: fn(int)) { it(0); it(1); } fn main() { let a: [mutable int] = [mutable -1, -1, -1, -1]; let mut p: int = 0; two {|i| two {|j| a[p] = 10 * i + j; p += 1; }; }; assert (a[0] == 0); assert (a[1] == 1); assert (a[2] == 10); assert (a[3] == 11); } // -*- rust -*- fn two(it: fn(int)) { it(0); it(1); } fn main() { let a: [mut int] = [mut -1, -1, -1, -1]; let mut p: int = 0; two {|i| two {|j| a[p] = 10 * i + j; p += 1; }; }; assert (a[0] == 0); assert (a[1] == 1); assert (a[2] == 10); assert (a[3] == 11); } // -*- rust -*- fn two(it: fn(int)) { it(0); it(1); } fn main() { let a: [mut int]/~ = [mut -1, -1, -1, -1]/~; let mut p: int = 0; two {|i| two {|j| a[p] = 10 * i + j; p += 1; }; }; assert (a[0] == 0); assert (a[1] == 1); assert (a[2] == 10); assert (a[3] == 11); } // -*- rust -*- fn two(it: fn(int)) { it(0); it(1); } fn main() { let a: ~[mut int] = ~[mut -1, -1, -1, -1]; let mut p: int = 0; two {|i| two {|j| a[p] = 10 * i + j; p += 1; }; }; assert (a[0] == 0); assert (a[1] == 1); assert (a[2] == 10); assert (a[3] == 11); } // -*- rust -*- fn two(it: fn(int)) { it(0); it(1); } fn main() { let a: ~[mut int] = ~[mut -1, -1, -1, -1]; let mut p: int = 0; do two {|i| do two {|j| a[p] = 10 * i + j; p += 1; } } assert (a[0] == 0); assert (a[1] == 1); assert (a[2] == 10); assert (a[3] == 11); } // -*- rust -*- fn two(it: fn(int)) { it(0); it(1); } fn main() { let a: ~[mut int] = ~[mut -1, -1, -1, -1]; let mut p: int = 0; do two |i| { do two |j| { a[p] = 10 * i + j; p += 1; } } assert (a[0] == 0); assert (a[1] == 1); assert (a[2] == 10); assert (a[3] == 11); } // Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or distributed // except according to those terms. // -*- rust -*- fn two(it: fn(int)) { it(0); it(1); } fn main() { let a: ~[mut int] = ~[mut -1, -1, -1, -1]; let mut p: int = 0; do two |i| { do two |j| { a[p] = 10 * i + j; p += 1; } } assert (a[0] == 0); assert (a[1] == 1); assert (a[2] == 10); assert (a[3] == 11); } // Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or distributed // except according to those terms. // -*- rust -*- fn two(it: fn(int)) { it(0); it(1); } fn main() { let mut a: ~[mut int] = ~[-1, -1, -1, -1]; let mut p: int = 0; do two |i| { do two |j| { a[p] = 10 * i + j; p += 1; } } assert (a[0] == 0); assert (a[1] == 1); assert (a[2] == 10); assert (a[3] == 11); } // Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or distributed // except according to those terms. // -*- rust -*- fn two(it: fn(int)) { it(0); it(1); } fn main() { let mut a: ~[int] = ~[-1, -1, -1, -1]; let mut p: int = 0; do two |i| { do two |j| { a[p] = 10 * i + j; p += 1; } } assert (a[0] == 0); assert (a[1] == 1); assert (a[2] == 10); assert (a[3] == 11); } // Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or distributed // except according to those terms. // -*- rust -*- fn two(it: fn(int)) { it(0); it(1); } pub fn main() { let a: ~[mut int] = ~[mut -1, -1, -1, -1]; let mut p: int = 0; do two |i| { do two |j| { a[p] = 10 * i + j; p += 1; } } assert (a[0] == 0); assert (a[1] == 1); assert (a[2] == 10); assert (a[3] == 11); } // Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or distributed // except according to those terms. // -*- rust -*- fn two(it: fn(int)) { it(0); it(1); } pub fn main() { let mut a: ~[int] = ~[-1, -1, -1, -1]; let mut p: int = 0; do two |i| { do two |j| { a[p] = 10 * i + j; p += 1; } } assert (a[0] == 0); assert (a[1] == 1); assert (a[2] == 10); assert (a[3] == 11); } // Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or distributed // except according to those terms. // -*- rust -*- fn two(it: fn(int)) { it(0); it(1); } pub fn main() { let mut a: ~[int] = ~[-1, -1, -1, -1]; let mut p: int = 0; do two |i| { do two |j| { a[p] = 10 * i + j; p += 1; } } fail_unless!((a[0] == 0)); fail_unless!((a[1] == 1)); fail_unless!((a[2] == 10)); fail_unless!((a[3] == 11)); } // Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or distributed // except according to those terms. // -*- rust -*- fn two(it: &fn(int)) { it(0); it(1); } pub fn main() { let mut a: ~[int] = ~[-1, -1, -1, -1]; let mut p: int = 0; do two |i| { do two |j| { a[p] = 10 * i + j; p += 1; } } fail_unless!((a[0] == 0)); fail_unless!((a[1] == 1)); fail_unless!((a[2] == 10)); fail_unless!((a[3] == 11)); } // Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or distributed // except according to those terms. // -*- rust -*- fn two(it: &fn(int)) { it(0); it(1); } pub fn main() { let mut a: ~[int] = ~[-1, -1, -1, -1]; let mut p: int = 0; do two |i| { do two |j| { a[p] = 10 * i + j; p += 1; } } assert!((a[0] == 0)); assert!((a[1] == 1)); assert!((a[2] == 10)); assert!((a[3] == 11)); } // Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or distributed // except according to those terms. // -*- rust -*- fn two(it: &fn(int)) { it(0); it(1); } pub fn main() { let mut a: ~[int] = ~[-1, -1, -1, -1]; let mut p: int = 0; do two |i| { do two |j| { a[p] = 10 * i + j; p += 1; } } assert_eq!(a[0], 0); assert_eq!(a[1], 1); assert_eq!(a[2], 10); assert_eq!(a[3], 11); } // Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or distributed // except according to those terms. fn two(it: &fn(int)) { it(0); it(1); } pub fn main() { let mut a: ~[int] = ~[-1, -1, -1, -1]; let mut p: int = 0; do two |i| { do two |j| { a[p] = 10 * i + j; p += 1; } } assert_eq!(a[0], 0); assert_eq!(a[1], 1); assert_eq!(a[2], 10); assert_eq!(a[3], 11); } // Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or distributed // except according to those terms. fn two(it: |int|) { it(0); it(1); } pub fn main() { let mut a: ~[int] = ~[-1, -1, -1, -1]; let mut p: int = 0; do two |i| { do two |j| { a[p] = 10 * i + j; p += 1; } } assert_eq!(a[0], 0); assert_eq!(a[1], 1); assert_eq!(a[2], 10); assert_eq!(a[3], 11); } // Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or distributed // except according to those terms. fn two(it: |int|) { it(0); it(1); } pub fn main() { let mut a: ~[int] = ~[-1, -1, -1, -1]; let mut p: int = 0; two(|i| { two(|j| { a[p] = 10 * i + j; p += 1; }) }); assert_eq!(a[0], 0); assert_eq!(a[1], 1); assert_eq!(a[2], 10); assert_eq!(a[3], 11); } // Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or distributed // except according to those terms. fn two(it: |int|) { it(0); it(1); } pub fn main() { let mut a: Vec<int> = vec!(-1, -1, -1, -1); let mut p: int = 0; two(|i| { two(|j| { a[p] = 10 * i + j; p += 1; }) }); assert_eq!(a[0], 0); assert_eq!(a[1], 1); assert_eq!(a[2], 10); assert_eq!(a[3], 11); } // Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or distributed // except according to those terms. use std::vec_ng::Vec; fn two(it: |int|) { it(0); it(1); } pub fn main() { let mut a: Vec<int> = vec!(-1, -1, -1, -1); let mut p: int = 0; two(|i| { two(|j| { *a.get_mut(p as uint) = 10 * i + j; p += 1; }) }); assert_eq!(*a.get(0), 0); assert_eq!(*a.get(1), 1); assert_eq!(*a.get(2), 10); assert_eq!(*a.get(3), 11); } // Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or distributed // except according to those terms. fn two(it: |int|) { it(0); it(1); } pub fn main() { let mut a: Vec<int> = vec!(-1, -1, -1, -1); let mut p: int = 0; two(|i| { two(|j| { *a.get_mut(p as uint) = 10 * i + j; p += 1; }) }); assert_eq!(*a.get(0), 0); assert_eq!(*a.get(1), 1); assert_eq!(*a.get(2), 10); assert_eq!(*a.get(3), 11); } // Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or distributed // except according to those terms. fn two(it: |int|) { it(0); it(1); } pub fn main() { let mut a: Vec<int> = vec!(-1, -1, -1, -1); let mut p: int = 0; two(|i| { two(|j| { *a.get_mut(p as uint) = 10 * i + j; p += 1; }) }); assert_eq!(a[0], 0); assert_eq!(a[1], 1); assert_eq!(a[2], 10); assert_eq!(a[3], 11); } // Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or distributed // except according to those terms. fn two(it: |int|) { it(0); it(1); } pub fn main() { let mut a: Vec<int> = vec!(-1, -1, -1, -1); let mut p: int = 0; two(|i| { two(|j| { a[p as uint] = 10 * i + j; p += 1; }) }); assert_eq!(a[0], 0); assert_eq!(a[1], 1); assert_eq!(a[2], 10); assert_eq!(a[3], 11); } // Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or distributed // except according to those terms. fn two<F>(mut it: F) where F: FnMut(int) { it(0); it(1); } pub fn main() { let mut a: Vec<int> = vec!(-1, -1, -1, -1); let mut p: int = 0; two(|i| { two(|j| { a[p as uint] = 10 * i + j; p += 1; }) }); assert_eq!(a[0], 0); assert_eq!(a[1], 1); assert_eq!(a[2], 10); assert_eq!(a[3], 11); } // Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or distributed // except according to those terms. // pretty-expanded FIXME #23616 fn two<F>(mut it: F) where F: FnMut(int) { it(0); it(1); } pub fn main() { let mut a: Vec<int> = vec!(-1, -1, -1, -1); let mut p: int = 0; two(|i| { two(|j| { a[p as uint] = 10 * i + j; p += 1; }) }); assert_eq!(a[0], 0); assert_eq!(a[1], 1); assert_eq!(a[2], 10); assert_eq!(a[3], 11); } // Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or distributed // except according to those terms. // pretty-expanded FIXME #23616 fn two<F>(mut it: F) where F: FnMut(isize) { it(0); it(1); } pub fn main() { let mut a: Vec<isize> = vec!(-1, -1, -1, -1); let mut p: isize = 0; two(|i| { two(|j| { a[p as usize] = 10 * i + j; p += 1; }) }); assert_eq!(a[0], 0); assert_eq!(a[1], 1); assert_eq!(a[2], 10); assert_eq!(a[3], 11); } // Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or distributed // except according to those terms. fn two<F>(mut it: F) where F: FnMut(isize) { it(0); it(1); } pub fn main() { let mut a: Vec<isize> = vec!(-1, -1, -1, -1); let mut p: isize = 0; two(|i| { two(|j| { a[p as usize] = 10 * i + j; p += 1; }) }); assert_eq!(a[0], 0); assert_eq!(a[1], 1); assert_eq!(a[2], 10); assert_eq!(a[3], 11); }