Coroutines, Self-Referential Structs, and Pinning 230 6. The next time we poll the future, we restore the stack by dereferencing the pointer we hold for our writer variable. However, there's a big problem: the pointer is now pointing to the old location on the stack where the future was located at the first poll. 7. That can't end well, and it doesn't in our case. Y ou've now seen firsthand the problem with self-referential structs, how this applies to futures, and why we need something that prevents this from happening. A self-referential struct is a struct that takes a reference to self and stores it in a field. Now, the term reference here is a little bit unprecise since there is no way to take a reference to self in Rust and store that reference in self. To do this in safe Rust, you have to cast the reference to a pointer (remember that references are just pointers with a special meaning in the programming language). Note When we create visualizations in this chapter, we'll disregard padding, even though we know structs will likely have some padding between fields, as we discussed in Chapter 4. When this value is moved to another location in memory, the pointer is not updated and points to the “old” location. If we take a look at a move from one location on the stack to another one, it looks something like this: Figure 9. 1-Moving a self-referential struct In the preceding figure, we can see the memory addresses to the left with a representation of the stack next to it. Since the pointer was not updated when the value was moved, it now points to the old location, which can cause serious problems. 