Hacker News new | past | comments | ask | show | jobs | submit login

Great! So, let's refactor that UI code out into a function. Something a beginner is very likely to do as that code becomes more complex.

Oops. The borrow checker is going to beat you over the head. And beginners aren't likely to understand that it isn't their fault.

Rust needs to figure out a way to do GUIs ergonomically without requiring closures.




Which UI code specifically are you referring to and why would the borrow checker prevent you from factoring it out?


Well, I think the one that stuck out was here: https://github.com/SixArm/rust-guideposts/blob/main/projects...

But here: https://github.com/gtk-rs/gtk4-rs/blob/master/examples/text_...

and here: https://github.com/gtk-rs/gtk4-rs/blob/master/examples/clock...

The moment some poor slob of a beginner tries to refactor any of those closures into a "normal" function, they're going to get beat over the head by the borrow checker.

Yes, I know why they're required in Rust. And it makes sense once you know Rust well. But a beginner isn't likely to understand why they can't refactor a closure into a function in Rust without a whole lot of clone().

Coding "examples" for Rust need to stop using that closure style--especially in "beginner" code.




Consider applying for YC's Summer 2025 batch! Applications are open till May 13

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: