2 // compile-flags: --edition=2021 --crate-type=lib
14 pub trait Object
<'a
> {
16 type Future
: Future
<Output
= Self>;
17 fn create() -> Self::Future
;
20 impl<'a
> Object
<'a
> for u8 {
22 type Future
= Pin
<Box
<dyn Future
<Output
= Self>>>;
23 fn create() -> Self::Future
{
28 impl<'a
, E
, A
: Object
<'a
, Error
= E
>> Object
<'a
> for (A
,) {
30 type Future
= CustomFut
<'a
, E
, A
>;
31 fn create() -> Self::Future
{
36 pub struct CustomFut
<'f
, E
, A
: Object
<'f
, Error
= E
>> {
37 ph
: PhantomData
<(A
::Future
,)>,
40 impl<'f
, E
, A
: Object
<'f
, Error
= E
>> Future
for CustomFut
<'f
, E
, A
> {
42 fn poll(self: Pin
<&mut Self>, _
: &mut Context
<'_
>) -> Poll
<Self::Output
> {
52 type Future
: Future
<Output
= ()>;
53 fn call(&self) -> Self::Future
;
56 impl<F
, Fut
> AsyncFn
for F
59 Fut
: Future
<Output
= ()>,
62 fn call(&self) -> Self::Future
{
69 use self::{async_fn::AsyncFn, object::Object}
;
71 async
fn create
<T
: Object
<'
static>>() {
75 async
fn call_async_fn(inner
: impl AsyncFn
) {
79 call_async_fn(create
::<(u8,)>).await
;