1 hour ago · 13 min read2697 words · Tech · hide · 0 comments

IntroductionIn my post on Hoisting Expressions I discussed the move($expr) feature and how it works much like an inverse of the defer feature many languages have. Instead of creating expressions which run after the scope ends, move($expr) runs code before the scope is entered 1. The goal of this code is to make it so clone-heavy ecosystems like bevy have a much better experience using Rust. 1Actually it’s run at closure instantiation time, but that’s also before from the perspective of the closure body. Even though I agree with the goals, I’m less sure about the proposal. I feel that explicit capture clauses provide a simpler model and are therefore preferable. But they have the downside they can feel a bit clunky to write and can break up the writing flow. And so in this post I want to explore a potential solution here by making the conversion of references to owned values a first-class language feature. Setting the stageLet’s start by using a simplified version of the motivating…

No comments yet. Log in to reply on the Fediverse. Comments will appear here.