https://play.rust-lang.org/?version=nightly&mode=debug&edition=2021&gist=d383ef3aefad236b54486affe9c59a27
#![feature(type_alias_impl_trait)]
use std::future::Future;
use std::io::Result;
use std::pin::Pin;
pub trait AsyncReadFrom: Sized {
type Output<R>: Future<Output = Self>;
fn async_read_from<R: Unpin>(r: &mut R) -> Self::Output<R>;
}
impl<T: AsyncReadFrom> AsyncReadFrom for (T,) {
type Output<R> = impl Future<Output = Self>;
fn async_read_from<R: Unpin>(r: &mut R) -> Self::Output<R> {
let r = Pin::new(r);
async move {
while true {
T::async_read_from(r.get_mut()).await;
}
loop {}
}
}
}
https://play.rust-lang.org/?version=nightly&mode=debug&edition=2021&gist=d383ef3aefad236b54486affe9c59a27