this basic tokio example, I got error
the trait bound fn() -> impl std::future::Future {hello}: std::future::Future
is not satisfied: the trait std::future::Future
is not implemented for fn() -> impl std::future::Future {hello}
however, rt.block_on(async { println!("Hello"); }); works. Why? what's the difference? Thanks.
use tokio::runtime::Runtime;
use tokio::prelude::*;
fn main() {
let mut rt = Runtime::new().unwrap();
rt.block_on(hello);
// This works
// rt.block_on(async { println!("Hello"); });
}
async fn hello() {
println!("hello");
}
in Cargo.toml
[dependencies]
tokio = { version = "0.2", features = ["rt-core", "tcp", "macros", "dns", "io-util"] }