2018-08-30 12:18:55 +00:00
|
|
|
// run-pass
|
2015-12-03 01:31:49 +00:00
|
|
|
#![feature(fn_traits, unboxed_closures)]
|
2014-12-23 05:09:40 +00:00
|
|
|
use std::ops::Fn;
|
|
|
|
|
|
|
|
struct Foo<T>(T);
|
|
|
|
|
2015-01-12 15:27:25 +00:00
|
|
|
impl<T: Copy> Fn<()> for Foo<T> {
|
2014-12-23 05:09:40 +00:00
|
|
|
extern "rust-call" fn call(&self, _: ()) -> T {
|
|
|
|
match *self {
|
|
|
|
Foo(t) => t
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-03-11 14:08:33 +00: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-23 05:09:40 +00:00
|
|
|
fn main() {
|
|
|
|
let t: u8 = 1;
|
|
|
|
println!("{}", Foo(t)());
|
|
|
|
}
|