Re:What Is Rust's Unsafe? (2019)
by oconnor663 on Sunday April 10, 2022 @04:41PM
(#30981488)
Yeah if you don't need mutation after initialization is done, Arc<T> is a good option for sharing. Lazy<T> (https://docs.rs/once_cell/latest/once_cell/sync/struct.Lazy....) is also nice, especially if you want to keep treating it like a global. I believe something like Lazy<T> is eventually going to be included in the standard library.
[ Parent
| on HN ]
It's already on nightly: https://doc.rust-lang.org/std/lazy/struct.Lazy.html