use std::{future::Future, ops::Deref, pin::Pin, sync::Arc}; pub struct LazyResolve( Arc Pin> + Send>> + Send + Sync>, ); impl LazyResolve { pub fn new( func: Box< dyn Fn() -> Pin> + Send>> + Send + Sync, >, ) -> Self { Self(Arc::new(func)) } pub async fn call(&self) -> anyhow::Result<()> { // Bad hack until .call becomes stable (self.0)().await } } impl Deref for LazyResolve { type Target = Arc Pin> + Send>> + Send + Sync>; fn deref(&self) -> &Self::Target { &self.0 } }