@@ -11,27 +11,21 @@ remove `std::thread_local` from the standard library.
11
11
# Motivation
12
12
13
13
Thread locals are directly related to threading. Combining the modules
14
- would reduce the number of top level modules, making browsing the docs
15
- easier as well as reduce the number of ` use ` statements.
14
+ would reduce the number of top level modules, combine related concepts,
15
+ and make browsing the docs easier. It also would have the potential to
16
+ slightly reduce the number of ` use ` statementsl
16
17
17
18
# Detailed design
18
19
19
- The goal is to move the contents of ` std::thread_local ` into
20
- ` std::thread ` . There are a few possible strategies that could be used to
21
- achieve this .
20
+ The ` std::thread_local ` module would be renamed to ` std::thread::local ` .
21
+ All contents of the module would remain the same. This way, all thread
22
+ related code is combined in one module .
22
23
23
- One option would be to move the contents as is into ` std::thread ` . This
24
- would leave ` Key ` and ` State ` as is. There would be no naming conflict,
25
- but the names would be less ideal since the containing module is not
26
- directly related to thread locals anymore. This could be handled by
27
- renaming the types to something like ` LocalKey ` and ` LocalState ` .
24
+ It would also allow using it as such:
28
25
29
- Another option would be to move the contents into a dedicated sub module
30
- such as ` std::thread::local ` . This would mean some code would still have
31
- an extra ` use ` statement for pulling in thread local related types, but
32
- it would also enable doing:
33
-
34
- ` use std::thread::{local, Thread}; `
26
+ ``` rust
27
+ use std :: thread :: {local, Thread };
28
+ ```
35
29
36
30
# Drawbacks
37
31
@@ -42,7 +36,11 @@ may prefer to have more top level modules.
42
36
43
37
# Alternatives
44
38
45
- Leaving ` std::thread_local ` in its own module.
39
+ Another strategy for moving ` std::thread_local ` would be to move it
40
+ directly into ` std::thread ` without scoping it in a dedicated module.
41
+ There are no naming conflicts, but the names would not be ideal anymore.
42
+ One way to mitigate would be to rename the types to something like
43
+ ` LocalKey ` and ` LocalState ` .
46
44
47
45
# Unresolved questions
48
46
0 commit comments