Reputation: 713
I am following Rust's async/await primer but am having trouble running the hello world program shown below.
use futures::executor::block_on;
async fn hello_world() {
println!("hello, world!");
}
fn main() {
let future = hello_world(); // Nothing is printed
block_on(future); // `future` is run and "hello, world!" is printed
}
I receive the error:
1 | use futures::executor::block_on;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ no `block_on` in `executor`
Is there an import required to use this function?
Upvotes: 0
Views: 1775
Reputation: 713
As mentioned by Stargateur, futures = { version = "0.3", features = ["compat"] }
needs to be added to your Cargo.toml dependencies.
The dependency is indicated at the top of the page following the hello world example.
Upvotes: 2