1 #![feature(unsized_locals)]
2 #![feature(unboxed_closures)]
3 #![feature(tuple_trait)]
5 pub trait FnOnce<Args: std::marker::Tuple> {
7 extern "rust-call" fn call_once(self, args: Args) -> Self::Output;
12 impl FnOnce<()> for A {
14 extern "rust-call" fn call_once(self, (): ()) -> Self::Output {
21 impl FnOnce<()> for B {
23 extern "rust-call" fn call_once(self, (): ()) -> Self::Output {
30 impl FnOnce<()> for C {
32 extern "rust-call" fn call_once(self, (): ()) -> Self::Output {
37 struct D(Box<String>);
39 impl FnOnce<()> for D {
41 extern "rust-call" fn call_once(self, (): ()) -> Self::Output {
48 let x = *(Box::new(A) as Box<dyn FnOnce<(), Output = String>>);
49 assert_eq!(x.call_once(()), format!("hello"));
50 let x = *(Box::new(B(42)) as Box<dyn FnOnce<(), Output = String>>);
51 assert_eq!(x.call_once(()), format!("42"));
52 let x = *(Box::new(C(format!("jumping fox"))) as Box<dyn FnOnce<(), Output = String>>);
53 assert_eq!(x.call_once(()), format!("jumping fox"));
54 let x = *(Box::new(D(Box::new(format!("lazy dog")))) as Box<dyn FnOnce<(), Output = String>>);
55 assert_eq!(x.call_once(()), format!("lazy dog"));