The Mystery of the Pin
summary
Explains why Pin stops moves by blocking access to the pointers or mutable references needed for a mem copy, shows how self‑referential structs break naive moves, and demonstrates wrapping a TcpStream with metrics to reveal the generic-T problem. Uses mem::swap, the Unpin auto‑trait, and the pin_project / pin_project_lite macro to generate safe field projection. Notes that async futures are !Unpin, that most types are Unpin so Pin is usually a no‑op, and that mem::swap and pin_project let the wrapper work while pin_project_light forbids implementing Drop (pin_project supports PinDrop).
AI-written summary · about
chapters (9)
- 0:00Start
- 2:03MOVE BY "MEMCPY"
- 2:47MOVE SEMANTICS
- 3:57MOVING POINTERS
- 4:28SNEAKY MOVE
- 5:46SELF-REFERENTIAL STRUCT
- 6:49ASYNC BLOCKS & FUNCTIONS
- 9:05PIN IS FOR POINTERS
- 12:46IN SHORT
related talks
26mpin-init: Solving Address Stability in Rust
01h 06mThe Hidden Secrets of Move Semantics
07mType punning done right
46mExploring lending async iterators
32mBeyond the &: A Future for Native Smart Pointers in Rust
24mMove Constructors: Is it Possible?
38mInitialization in Rust with pin-init
54mpinned_vector
