Coroutines and async/await 158 fn main() { let start = Instant::now(); let mut future = async_main(); loop { match future. poll() { Poll State::Not Ready => (), Poll State::Ready(_) => break, } } println!("\n ELAPSED TIME: {}", start. elapsed(). as_secs_f32()); } This code contains a few changes. First, we add a convenience function for creating new paths for our GET request called get_path to create a path we can use in our GET request with a delay and a message based on the integer we pass in. Next, in our async_main function, we create five requests with delays varying from 0 to 4 seconds. The last change we've made is in our main function. We no longer print out a message on every call to poll, and therefore, we don't use thread::sleep to limit the number of calls. Instead, we measure the time from when we enter the main function to when we exit it because we can use that as a way to prove whether our code runs concurrently or not. Now that our main. rs looks like the preceding example, we can use corofy to rewrite it into a state machine, so assuming we're in the root folder of ch07/b-async-await, we can write the following: corofy. /src/main. rs That should output a file called main_corofied. rs in the src folder that you can open and inspect. Now, you can copy all the contents of main_corofied. rs in this file and paste it into main. rs. Note For convenience, there is a file called original_main. rs in the root of the project that contains the code for main. rs that we presented, so you don't need to save the original content of main. rs. If you write out every example yourself by copying it from the book in your own project, it would be smart to store the original contents of main. rs somewhere before you overwrite it. I won't show the entire state machine here since the 39 lines of code using coroutine/wait end up being 170 lines of code when written as a state machine, but our State enum now looks like this: enum State0 { Start, Wait1(Box<dyn Future<Output = String>>),