rust-lang-nursery / lazy-static.rs

A small macro for defining lazy evaluated static variables in Rust.
Apache License 2.0
1.91k stars 111 forks source link

Thread-local lazy static #82

Open jethrogb opened 7 years ago

jethrogb commented 7 years ago

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.

Kimundi commented 6 years ago

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.

tuxzz commented 5 years ago

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.