Coroutines, Self-Referential Structs, and Pinning 220 //--------------------------------- let fut1 = Box::new( http::Http::get("/600/ Hello Async Await")); self. state = State0::Wait1(fut1); // save stack } Okay, so there are some important changes here that I've highlighted. Let's go through them: The first thing we do when we're in the Start state is add a segment at the top where we initialize our stack. One of the things we do is hoist all variable declarations for the relevant code section (in this case, before the first wait point) to the top of the function. In our example, we also initialize the variables to their initial value, which in this case is 0. We also added a comment stating that we should save the stack, but since all that happens before the first wait point is the initialization of counter, there is nothing to store here. Let's take a look at what happens after the first wait point: ch09/a-coroutines-variables/src/main. rs State0::Wait1(ref mut f1) => { match f1. poll(waker) { Poll State::Ready(txt) => { // Restore stack let mut counter = self. stack. counter. take(). unwrap(); //----Code you actually wrote---- println!("{txt}"); counter += 1; //--------------------------------- let fut2 = Box::new( http::Http::get("/400/ Hello Async Await")); self. state = State0::Wait2(fut2); // save stack self. stack. counter = Some(counter); } Poll State::Not Ready => break Poll State::Not Ready, } }