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

That is correct. Kinda. Refcell can not work because Rust considers globals to be shared by multiple threads so requires thread safety.

And that’s where a number of people blow a gasket.



A second component is that statics require const initializers, so for most of rust’s history if you wanted a non-trivial global it was either a lot of faffing about or using third party packages (lazy_static, once_cell).

Since 1.80 the vast majority of uses are a LazyLock away.




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

Search: