How to create a thread local variable inside of a Rust struct?
问题 I need a thread local variable, ideally stored in a struct which currently stores most of my program's global state. The first way I can see to do this is to use the thread_local! macro, however I would like to keep this thread local within my state struct. The second way I can see to achieve this is to have a HashMap<Thread,MyThreadLocalData> or similar between threads and the value of my thread local variable(s). I would then have a getter which uses thread::current to lookup the