Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

This is very useful, so useful that I can't help but think that the compiler actually should say what you said.


I definitely think the error could be improved but I'm not sure it should really say "just shove it in an `Arc<Mutex>`," because that really is only sometimes the right solution and it might lead people to make poor choices by default.

I think a lot of the problem is really with the confusingness of the concept of static lifetime in rust to begin with, where it's kinda used for both "lives forever" and "doesn't reference anything that lives longer than it"[1]. I hope someday these meanings get different names, tbh.

But when you see that error the naive thought is like... "ok better make it live forever" but it really just means you need to make it something that you control, and there are other ways to do that than a refcounting mutex.

[1] https://doc.rust-lang.org/rust-by-example/scope/lifetime/sta...


That's very useful, thanks! I need to learn more Rust.


That's very useful, thanks!


Try raising an issue on GitHub. Rust people are interested in improvements like that. I'm not saying it will be accepted, but it won't be ignored.




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

Search: