Hacker News new | ask | show | jobs
by leshow 2750 days ago
I got lost in the weeds fairly quickly with this blog post, why is it that you didn't have to implement Future?

Pinning is required here because your AsyncRead read_to_end returns a future bound by some reference lifetime?

1 comments

The actual Future implementation comes from std, std::future::from_generator takes a generator with the right associated types and turns it into a future.

Yep, the generator created by quote_encrypt_unquote is creating internal self-references from the future created by read_to_end into the AsyncRead it's storing in its environment, while this is happening the AsyncRead must not move and therefore the generator must not move, which is what pinning represents.