News for hackers. Stuff that matters.
Re:A Rust Shaped Hole by bsder on Wednesday July 16, 2025 @09:38PM (#44588856)
> Rust is the easiest language to refactor with I've ever worked in

Oh? So how do you refactor a closure into a named function in Rust?

I have found this to be of the most common failure modes that makes people want to punch the monitor.

(Context: in almost all programming languages, a closure is practically equivalent to an unnamed function--refactoring a closure to a named function tends to be pretty straightforward. This isn't true for Rust--closures pick up variable lifetime information that can be excruciatingly difficult to unwind to a named function.)

Re:A Rust Shaped Hole by bryanlarsen on Wednesday July 16, 2025 @09:52PM (#44588924)
Set the type of all the parameters to your new function to bool, then compile. The compiler error will tell you, "Error: you passed a foo<'bar, baz> instead of a bool". Then you change the type in the function's parameter to "foo<'bar, baz>".
Re:A Rust Shaped Hole by afdbcreid on Thursday July 17, 2025 @01:29AM (#44589983)
You invoke the assist of rust-analyzer that does that automatically.