An example of hand-written coroutines 149 Wait1 : When we call Http::get, we get a Http Get Future returned that we store in the State enum. At this point, we return control back to the calling function so it can do other things if needed. We chose to make this generic over all Future functions that output a String, but since we only have one kind of future right now, we could have made it simply hold a Http Get Future and it would work the same way. Wait2 : The second call to Http::get is the second place where we'll pass control back to the calling function. Resolved : The future is resolved and there is no more work to do. Note We could have simply defined Coroutine as an enum since the only state it holds is an enum indicating its state. But, we'll set up this example so we can add some state to Coroutine later on in this book. Next is the implementation of Coroutine : ch07/a-coroutine/src/main. rs impl Coroutine { fn new()-> Self { Self { state: State::Start, } } } So far, this is pretty simple. When creating a new Coroutine, we simply set it to State::Start and that's it. Now we come to the part where the work is actually done in the Future implementation for Coroutine. I'll walk you through the code: ch07/a-coroutine/src/main. rs impl Future for Coroutine { type Output = (); fn poll(&mut self)-> Poll State<Self::Output> { loop { match self. state { State::Start => { println!("Program starting"); let fut = Box::new(Http::get("/600/Hello World1"));