use std::task::{Context, Poll}; use futures_util::task::noop_waker_ref; use crate::prelude::*; pub fn sync_future(future: impl Future) -> Result { let waker = noop_waker_ref(); let mut context = Context::from_waker(waker); pin!(future); if let Poll::Ready(a) = future.poll(&mut context) { Ok(a) } else { Err(anyhow::Error::msg("Future has suspended")) } }