Pin, Unpin, and why Rust needs them
The text discusses the implementation of async Rust libraries and the concept of self-referential types. It explains how futures work, why they were unsafe initially, and how Pin/Unpin made them safe. The author also demonstrates using Pin/Unpin to write tricky nested futures. He provides a detailed example of implementing a TimedWrapper that wraps an async function and collects metrics about it. The post concludes with a summary of the key points discussed, emphasizing the importance of understanding self-referential types and how Pin/Unpin can be used to write safe code in Rust.
Company
Cloudflare
Date published
Aug. 26, 2021
Author(s)
Adam Chalmers
Word count
2375
Language
English
Hacker News points
37