crate::cfg::switch! {
#[cfg(feature = "async-io")] => {
pub use async_io::block_on;
}
#[cfg(feature = "futures-lite")] => {
pub use futures_lite::future::block_on;
}
_ => {
pub fn block_on<T>(future: impl Future<Output = T>) -> T {
use core::task::{Poll, Context};
let mut future = core::pin::pin!(future);
let cx = &mut Context::from_waker(core::task::Waker::noop());
loop {
match future.as_mut().poll(cx) {
Poll::Ready(output) => return output,
Poll::Pending => core::hint::spin_loop(),
}
}
}
}
}