#![allow(unused)] use ::std::{ pin::Pin, future::Future, task::{Context, Poll}, }; use ::easy_pin::easy_pin; #[easy_pin(Unpin)] struct Map { #[transitively_pinned] future: Fut, #[unpinned] f_opt: Option, } impl Future for Map where Fut : Future, F : FnOnce(Fut::Output) -> Ret, { type Output = Ret; fn poll ( mut self: Pin<&'_ mut Self>, cx: &'_ mut Context, ) -> Poll { match self.as_mut().pinned_future_mut().poll(cx) { // | Poll::Pending => Poll::Pending, | Poll::Ready(output) => { let f = self.unpinned_f_opt_mut() .take() .expect(concat!( "Map must not be polled after ", "it returned `Poll::Ready`", )); Poll::Ready(f(output)) }, } } } fn main () {}