mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-24 15:54:15 +00:00
19 lines
333 B
Rust
19 lines
333 B
Rust
// run-pass
|
|
#![feature(unboxed_closures)]
|
|
#![feature(fn_traits)]
|
|
|
|
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));
|
|
}
|