summaryrefslogtreecommitdiffstats
path: root/src/test/ui/closures/old-closure-iter-2.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/ui/closures/old-closure-iter-2.rs')
-rw-r--r--src/test/ui/closures/old-closure-iter-2.rs15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/test/ui/closures/old-closure-iter-2.rs b/src/test/ui/closures/old-closure-iter-2.rs
new file mode 100644
index 000000000..e90c1ee81
--- /dev/null
+++ b/src/test/ui/closures/old-closure-iter-2.rs
@@ -0,0 +1,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);
+}