use std::{ future::Future, pin::Pin, task::{Context, Poll}, }; pub struct Ready { val: Option, } impl Ready { #[inline] pub fn into_inner(mut self) -> T { self.val.take().unwrap() } } impl Unpin for Ready {} impl Future for Ready { type Output = T; #[inline] fn poll(mut self: Pin<&mut Self>, _cx: &mut Context<'_>) -> Poll { let val = self.val.take().expect("Ready polled after completion"); Poll::Ready(val) } } pub fn ready(val: T) -> Ready { Ready { val: Some(val) } }