<p><span class="h-card"><a href="https://hachyderm.io/@fasterthanlime" class="u-url mention">@<span>fasterthanlime</span></a></span> There's also <a href="https://docs.rs/tokio/latest/tokio/macro.task_local.html" target="_blank" rel="nofollow noopener noreferrer"><span class="invisible">https://</span><span class="ellipsis">docs.rs/tokio/latest/tokio/mac</span><span class="invisible">ro.task_local.html</span></a> that also works for async functions without the need to do things manually with thread locals.</p><p>Also you should look at why scoped futures aren't sound and why the original scoped thread APIs weren't sound because it might apply to your solution (haven't looked into it though, just listened to your podcast a minute ago).</p>