After a quick look, I think it would require a fairly significant API rework that employs the use of guards (perhaps ThreadLocalGuard and ThreadLocalMutGuard) that could maybe impl Deref and DerefMut to the underlying value. In much the same way as IterMut is implemented:
OK after a fundamental Rust refresher, I think my original comment is partly correct. However, you have to also add a get_inner_mut method. I'll see if I can do a PR.
Based on a brief exchange with @Kestrer:
https://github.com/Amanieu/thread_local-rs/issues/31#issuecomment-1674568797
After a quick look, I think it would require a fairly significant API rework that employs the use of guards (perhaps
ThreadLocalGuard
andThreadLocalMutGuard
) that could maybe impl Deref and DerefMut to the underlying value. In much the same way asIterMut
is implemented:https://docs.rs/thread_local/latest/src/thread_local/lib.rs.html#468-471
Scratch that, I think I may have a working implementation.Nope, yeah I think guards may be needed