c-async-await—concurrent futures 163 The main function will be the same, as well as the imports and declarations at the start of the file, so I'll only present the coroutine/await functions that we've changed: coroutine fn request(i: usize) { let path = format!("/{}/Hello World{i}", i * 1000); let txt = Http::get(&path). wait; println!("{txt}"); } coroutine fn async_main() { println!("Program starting"); let mut futures = vec![]; for i in 0..5 { futures. push(request(i)); } future::join_all(futures). wait; } Note In the repository, you'll find the correct code to put in main. rs in ch07/c-async-await/ original_main. rs if you ever lose track of it with all the copy/pasting we're doing. Now we have two coroutine/wait functions. async_main stores a set of coroutines created by read_request in a Vec<T: Future>. Then it creates a Join All future and calls wait on it. The next coroutine/wait function is read_requests, which takes an integer as input and uses that to create GET requests. This coroutine will in turn wait for the response and print out the result once it arrives. Since we create the requests with delays of 0, 1, 2, 3, 4 seconds, we should expect the entire program to finish in just over four seconds because all the tasks will be in progress concurrently. The ones with short delays will be finished by the time the task with a four-second delay finishes. We can now transform our coroutine/await functions into state machines by making sure we're in the folder ch07/c-async-await and writing corofy. /src/main. rs. Y ou should now see a file called main_corofied. rs in the src folder. Copy its contents and replace what's in main. rs with it.