You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Originally we used lazy_static in ring::rand because static didn't work for types that implement Drop, as File does. That restriction was removed in rust-lang/rust#44456. I believe it should now be possible to get the same effects using just std::sync::Once.
@bpowers nicely wrote a PR to do this. That PR taught me a lot about this issue; in particular it taught me that switching to direct of of static mut is a bad idea. I had originally overlooked that using static mut directly would require us to use unsafe where we previously didn't need to.
Regarding the issues with lazy_static linked to above, after I read @bpowers's PR I went back through them again and noticed that the discussion of those issues was pointing out how dangerous direct use of static mut is. Also, the issues with lazy_static have been resolved as of lazy_static 1.2. I upgraded ring's dependency to use version 1.2.
There are simpler and marginally better alternatives to lazy_static, e.g. ones that aren't as obfuscated with macros. Also, there have been proposals to provide a similar mechanism in libstd/libcore. Still, right now lazy_static appears to be, at worst, good enough. So I'm closing this issue.
Originally we used lazy_static in
ring::rand
becausestatic
didn't work for types that implementDrop
, asFile
does. That restriction was removed in rust-lang/rust#44456. I believe it should now be possible to get the same effects using juststd::sync::Once
.I see there are some (potential) problems with
lazy_static!
such as rust-lang-nursery/lazy-static.rs#116 and rust-lang-nursery/lazy-static.rs#117 and rust-lang-nursery/lazy-static.rs#125.The text was updated successfully, but these errors were encountered: