Use the Future01CompatExt
trait:
use futures01::future as future01;
use futures03::compat::Future01CompatExt;
fn make_future_01() -> impl future01::Future<Item = i32, Error = ()> {
future01::ok(2)
}
async fn example_03_uses_01() -> Result<i32, ()> {
let v = make_future_01().compat().await?;
Ok(v)
}
[dependencies]
futures03 = { package = "futures", version = "0.3", features = ["compat"] }
futures01 = { package = "futures", version = "0.1" }
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…