2018-08-30 14:18:55 +02:00
|
|
|
//@ run-pass
|
2015-12-02 17:31:49 -08:00
|
|
|
#![feature(fn_traits, unboxed_closures)]
|
2014-12-22 21:09:40 -08:00
|
|
|
struct Foo<T>(T);
|
|
|
|
|
|
2015-01-12 10:27:25 -05:00
|
|
|
impl<T: Copy> Fn<()> for Foo<T> {
|
2014-12-22 21:09:40 -08:00
|
|
|
extern "rust-call" fn call(&self, _: ()) -> T {
|
|
|
|
|
match *self {
|
|
|
|
|
Foo(t) => t
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2015-03-11 10:08:33 -04:00
|
|
|
impl<T: Copy> FnMut<()> for Foo<T> {
|
|
|
|
|
extern "rust-call" fn call_mut(&mut self, _: ()) -> T {
|
|
|
|
|
self.call(())
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl<T: Copy> FnOnce<()> for Foo<T> {
|
|
|
|
|
type Output = T;
|
|
|
|
|
|
|
|
|
|
extern "rust-call" fn call_once(self, _: ()) -> T {
|
|
|
|
|
self.call(())
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-12-22 21:09:40 -08:00
|
|
|
fn main() {
|
|
|
|
|
let t: u8 = 1;
|
|
|
|
|
println!("{}", Foo(t)());
|
|
|
|
|
}
|