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
Currently it's impossible to store structs with lifetime bounds in a scoped thread local, largely because rust doesn't support HKT. However, with macros and associated types, the type system is just powerful enough to express the required semantics.
Using the example implementation below, one can write code like the following:
The presence of 'scope allows a much wider range of types to be stored safely in a scoped thread local. Without this change the only way to get the same behaviour is via the use of unsafe code.
Currently it's impossible to store structs with lifetime bounds in a scoped thread local, largely because rust doesn't support HKT. However, with macros and associated types, the type system is just powerful enough to express the required semantics.
Using the example implementation below, one can write code like the following:
The presence of
'scope
allows a much wider range of types to be stored safely in a scoped thread local. Without this change the only way to get the same behaviour is via the use of unsafe code.Example implementation:
https://github.com/Diggsey/rust/tree/scoped_thread_local_hkt
(While it requires no changes to the compiler, changes to the compiler could make it significantly less hacky...)
The text was updated successfully, but these errors were encountered: