2 ms·
I'm not sure what you mean by closures being cumbersome in rust. Rust uses closures very heavily, for things like iterators, spawning threads, async tasks, and
by chlorion 3y ago
I'm not sure what you mean by closures being cumbersome in rust.
Rust uses closures very heavily, for things like iterators, spawning threads, async tasks, and lots of other things. I've never felt them to be cumbersome at all.
Actually, for me, closures in rust are easier to use than in any other language I have used besides for various lisps!
https://doc.rust-lang.org/book/ch13-01-closures.html https://doc.rust-lang.org/book/ch13-01-closures.html
- cube2222 3y agoWhen I say closure I mean anonymous functions that capture their environment, esp. in a mutable way. Those work fine in Rust for simple use-cases, but it gets annoying quickly. With a garbage collected language like Go, closures can freely capture stuff, use it, and then once no closure (or any other code, fwiw) references it anymore, it gets freed. Escape analysis and garbage collection make even more complex (like closures that outlive the scope) use cases (where lifetimes would be hell) trivial.