lazy-static.rs
lazy-static.rs copied to clipboard
Thread-local lazy static
lazy_static and std's thread_local are very similar concepts, but lazy_statics interface (with Deref) is much nicer. I think it should be possible to implement a thread-local version of lazy_static.
Indeed, some consistency between the two would be nice. I've always thought of that more as changing lazy_statics API to be closer to thread_local, but providing a wrapper for it with a nicer API seems like a interesting idea as well.
I've made a crate that combined lazy_static, thread_local and RefCell.
https://crates.io/crates/ref_thread_local
Do modification on lazy_static directly needs near fully rewrite so I create a new repository.