summaryrefslogtreecommitdiffstats
path: root/src/test/ui/functions-closures/capture-clauses-unboxed-closures.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/ui/functions-closures/capture-clauses-unboxed-closures.rs')
-rw-r--r--src/test/ui/functions-closures/capture-clauses-unboxed-closures.rs13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/test/ui/functions-closures/capture-clauses-unboxed-closures.rs b/src/test/ui/functions-closures/capture-clauses-unboxed-closures.rs
new file mode 100644
index 000000000..206b3d7b6
--- /dev/null
+++ b/src/test/ui/functions-closures/capture-clauses-unboxed-closures.rs
@@ -0,0 +1,13 @@
+// run-pass
+fn each<'a,T,F:FnMut(&'a T)>(x: &'a [T], mut f: F) {
+ for val in x {
+ f(val)
+ }
+}
+
+fn main() {
+ let mut sum = 0;
+ let elems = [ 1, 2, 3, 4, 5 ];
+ each(&elems, |val: &usize| sum += *val);
+ assert_eq!(sum, 15);
+}