summaryrefslogtreecommitdiffstats
path: root/src/test/ui/bare-fn-implements-fn-mut.rs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/test/ui/bare-fn-implements-fn-mut.rs27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/test/ui/bare-fn-implements-fn-mut.rs b/src/test/ui/bare-fn-implements-fn-mut.rs
new file mode 100644
index 000000000..dfead4889
--- /dev/null
+++ b/src/test/ui/bare-fn-implements-fn-mut.rs
@@ -0,0 +1,27 @@
+// run-pass
+
+use std::ops::FnMut;
+
+fn call_f<F:FnMut()>(mut f: F) {
+ f();
+}
+
+fn f() {
+ println!("hello");
+}
+
+fn call_g<G:FnMut(String,String) -> String>(mut g: G, x: String, y: String)
+ -> String {
+ g(x, y)
+}
+
+fn g(mut x: String, y: String) -> String {
+ x.push_str(&y);
+ x
+}
+
+fn main() {
+ call_f(f);
+ assert_eq!(call_g(g, "foo".to_string(), "bar".to_string()),
+ "foobar");
+}