Start with the idea
A future’s poll method receives Pin<&mut Self>. Some futures may have address-sensitive state, so the polling interface must not allow callers to move that state out after pinning. Unpin marks types for which the pinning restriction can be relaxed. Pin is not a mutex and does not itself provide synchronization or permanent storage.
The example pins a compiler-generated async future in a Box, records the pointee’s address, moves the Pin<Box<_>> handle and polls through its pinned mutable reference. Moving the handle does not relocate its heap pointee. A noop waker is adequate only because this particular future completes immediately; it is not a general executor for I/O or pending tasks.
Keep learning, for free
The rest of this lesson is waiting for you.
Create a free account to read the complete explanation, see the infographic, explore the code, and try the exercises. All 754 lessons and algorithm steps are included.
No payment details. Your account opens the complete Academy.