The async
/await
feature is coming soon, but there are a lot of libraries still using futures 0.1. How do we convert between the two?
Convert an async future to 0.1 future covers converting an async future to 0.1 future.
How do I erase the type of future in the new future API? talks about an async
function that calls an 0.1 future and gets the result, but where is the await!()
macro I can import? It seems it no longer compiles.
struct A_future01;
impl A_future01 {
pub fn exec1() -> Box<dyn Future<Item=String, Error=()>> {
Box::new(futures::future::result("ok"))
}
pub fn exec2() -> Box<dyn Future<Item=String, Error=()>> {
Box::new(call().unit_error().boxed().compat()) //Like this## Heading ##?
}
}
async fn call() -> Result<(), Box<dyn std::error::Error>> {
let result_from_a = A_future01::exec().await(); //how can I achieve this ?
Ok(())
}