use super::*; pub struct MutableFuture> { inner: Arc>>>, } impl> MutableFuture { pub fn new(inner: T) -> Self { Self { inner: Arc::new(Mutex::new(Box::pin(inner))), } } pub fn set(&self, inner: T) { *self.inner.lock() = Box::pin(inner); } } impl> Clone for MutableFuture { fn clone(&self) -> Self { Self { inner: self.inner.clone(), } } } impl> Future for MutableFuture { type Output = O; fn poll(self: Pin<&mut Self>, cx: &mut task::Context<'_>) -> task::Poll { let mut inner = self.inner.lock(); T::poll(inner.as_mut(), cx) } }