]> git.lizzy.rs Git - rust.git/commitdiff
Add regression test for #20544
authorCorey Farwell <coreyf@rwell.org>
Sun, 12 Jul 2015 11:34:08 +0000 (20:34 +0900)
committerCorey Farwell <coreyf@rwell.org>
Mon, 13 Jul 2015 13:25:19 +0000 (22:25 +0900)
Closes #20544

src/test/run-pass/issue-20544.rs [new file with mode: 0644]

diff --git a/src/test/run-pass/issue-20544.rs b/src/test/run-pass/issue-20544.rs
new file mode 100644 (file)
index 0000000..c70b059
--- /dev/null
@@ -0,0 +1,27 @@
+// Copyright 2015 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.
+
+#![feature(unboxed_closures)]
+#![feature(core)]
+
+struct Fun<F>(F);
+
+impl<F, T> FnOnce<(T,)> for Fun<F> where F: Fn(T) -> T {
+    type Output = T;
+
+    extern "rust-call" fn call_once(self, (t,): (T,)) -> T {
+        (self.0)(t)
+    }
+}
+
+fn main() {
+    let fun = Fun(|i: isize| i * 2);
+    println!("{}", fun(3));
+}