Coroutines, Self-Referential Structs, and Pinning 246 The next thing we need to change is to have the futures we store in our wait states pinned. We can do this by calling Box::pin instead of Box::new : ch09/e-coroutines-pin/src/main. rs let fut1 = Box:: pin(http::Http::get("/600/Hello Async Await")); let fut2 = Box:: pin(http::Http::get("/400/Hello Async Await")); The last place in main. rs where we need to make changes is in the locations where we poll our child futures since we now have to go through the Pin type to get a mutable reference: ch09/e-coroutines-pin/src/main. rs match f1. as_mut(). poll(waker) match f2. as_mut(). poll(waker) Note that we don't need unsafe here since these futures are !Unpin. The last place we need to change a few lines of code is in executor. rs, so let's head over there as our last stop. executor. rs The first thing we must do is make sure our dependencies are correct. The only change we're making here is adding Pin from the standard library: ch09/e-coroutines-pin/src/runtime/executor. rs... thread::{self, Thread}, pin::Pin, }; The next line we'll change is our Task type alias so that it now refers to Pin<Box<... >> : type Task = Pin<Box<dyn Future<Output = String>> >; The last line we'll change for now is in our spawn function. We have to pin the futures to the heap: e. tasks. borrow_mut(). insert(id, Box:: pin(future)); If we try to run our example now, it won't even compile and give us the following error: error[E0599]: no method named `poll` found for struct `Pin<Box<dyn future::Future<Output = String>>>` in the current scope --> src\runtime\executor. rs:89:30