我正在尝试在Rust中使用async/await处理进程。我正在使用tokio
和tokio-process
:
#![feature(await_macro, async_await, futures_api)]
extern crate tokio;
extern crate tokio_process;
use std::process::Command;
use tokio_process::CommandExt;
fn main() {
tokio::run_async(main_async());
}
async fn main_async() {
let out = Command::new("echo")
.arg("hello")
.arg("world")
.output_async();
let s = await!(out);
}
这是我收到的错误信息:
error[E0277]: the trait bound `tokio_process::OutputAsync: std::future::Future` is not satisfied
--> src/main.rs:21:13
|
21 | let s = await!(out);
| ^^^^^^^^^^^ the trait `std::future::Future` is not implemented for `tokio_process::OutputAsync`
|
= note: required by `std::future::poll_with_tls_waker`
= note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
error[E0277]: the trait bound `tokio_process::OutputAsync: std::future::Future` is not satisfied
--> src/main.rs:21:13
|
21 | let s = await!(out);
| ^^^^^^^^^^^ the trait `std::future::Future` is not implemented for `tokio_process::OutputAsync`
|
= note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
我该如何正确做到这一点?