I have tried Tokio tasks, but there are no working examples to execute multiple tasks at once. What is wrong with this code?
fn main() {
block_on(speak());
}
async fn speak() {
let hold = vec![say(), greet()];
let results = join_all(hold).await;
}
async fn say() {
println!("hello");
}
async fn greet() {
println!("world");
}
here is the compiler output
error[E0308]: mismatched types
--> sync\src\main.rs:14:27
|
14 | let hold = vec![say(),greet()];
| ^^^^^^^ expected opaque type, found a different opaque type
...
23 | async fn greet(){
| - the `Output` of this `async fn`'s found opaque type
|
= note: expected type `impl core::future::future::Future` (opaque type at <sync\src\main.rs:19:15>)
found opaque type `impl core::future::future::Future` (opaque type at <sync\src\main.rs:23:17>)
= note: distinct uses of `impl Trait` result in different opaque types