1 #![feature(unsized_locals)]
2 #![feature(unboxed_closures)]
4 pub trait FnOnce<Args> {
6 extern "rust-call" fn call_once(self, args: Args) -> Self::Output;
11 impl FnOnce<()> for A {
13 extern "rust-call" fn call_once(self, (): ()) -> Self::Output {
20 impl FnOnce<()> for B {
22 extern "rust-call" fn call_once(self, (): ()) -> Self::Output {
29 impl FnOnce<()> for C {
31 extern "rust-call" fn call_once(self, (): ()) -> Self::Output {
36 struct D(Box<String>);
38 impl FnOnce<()> for D {
40 extern "rust-call" fn call_once(self, (): ()) -> Self::Output {
47 let x = *(Box::new(A) as Box<dyn FnOnce<(), Output = String>>);
48 assert_eq!(x.call_once(()), format!("hello"));
49 let x = *(Box::new(B(42)) as Box<dyn FnOnce<(), Output = String>>);
50 assert_eq!(x.call_once(()), format!("42"));
51 let x = *(Box::new(C(format!("jumping fox"))) as Box<dyn FnOnce<(), Output = String>>);
52 assert_eq!(x.call_once(()), format!("jumping fox"));
53 let x = *(Box::new(D(Box::new(format!("lazy dog")))) as Box<dyn FnOnce<(), Output = String>>);
54 assert_eq!(x.call_once(()), format!("lazy dog"));