3 ms·
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/stru
by oconnor663 5y ago
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.html 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.
- jamincan 5y agoIt's already on nightly: https://doc.rust-lang.org/std/lazy/struct.Lazy.html https://doc.rust-lang.org/std/lazy/struct.Lazy.html