Re:My favorite Rust function
by The_rationalist on Saturday October 12, 2019 @09:20PM
(#21237601)
Interesting but this seems so unergonomic that I will still be virtually forced to not use static variables and thus loose their expressive power.
For example, use an atomic integer: https://play.rust-lang.org/?version=stable&mode=debug&editio...
You can also use types built on std::sync::Once and UnsafeCell, like once_cell::Lazy<std::sync::RwLock<T>>. This will get even easier as we get `const fn` constructors for locks in the future.