Any comments, contributions, or feedback? Ping me!

When should one use Rust’s Pin<>?

The other day I was reviewing some code from the Fendermint project that I am currently contributing to, and I had to ask the author of the PR directly, “man! you have to teach me when I am supposed to use Pin<>. I see you are using it all over the place in this API, but I don’t know why”. His immediate answer was a bit surprising although kind of expected. He answered, “I do compiler-driven development, so I don’t have a good answer for you”. It was kind of an expected answer because after some time writing code in Rust you get used to relying on the compiler for a lot of the heavy-lifting when writing more complex code in order to minimize your cognitive load.

However, after this immediate answer, he pointed me to an article from the Tokio team that did a great walk through of how, and why one, should use Pin<Box<<>> in certain cases when working with concurrent and asynchronous tasks. Let me directly link the publication here instead of paraphrasing in full. Enjoy!

Any comments, contributions, or feedback? Ping me!

;