Skip to content

Commit f853f0b

Browse files
committed
auto merge of #9160 : alexcrichton/rust/local-data-docs, r=huonw
Remove references to local_data::Key and only mention the macro for how to construct new keys into local data.
2 parents fbafb41 + d0462f0 commit f853f0b

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

src/libstd/local_data.rs

+8-7
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,10 @@ anywhere within a task, keyed by a global pointer parameterized over the type of
1717
the TLS slot. Useful for dynamic variables, singletons, and interfacing with
1818
foreign code with bad callback interfaces.
1919
20-
To use, declare a static variable of the type you wish to store. The
21-
initialization should be `&local_data::Key`. This is then the key to what you
22-
wish to store.
20+
To declare a new key for storing local data of a particular type, use the
21+
`local_data_key!` macro. This macro will expand to a `static` item apppriately
22+
named and annotated. This name is then passed to the functions in this module to
23+
modify/read the slot specified by the key.
2324
2425
~~~{.rust}
2526
use std::local_data;
@@ -31,14 +32,14 @@ local_data::set(key_int, 3);
3132
local_data::get(key_int, |opt| assert_eq!(opt, Some(&3)));
3233
3334
local_data::set(key_vector, ~[4]);
34-
local_data::get(key_int, |opt| assert_eq!(opt, Some(&~[4])));
35+
local_data::get(key_vector, |opt| assert_eq!(opt, Some(&~[4])));
3536
~~~
3637
37-
Casting 'Arcane Sight' reveals an overwhelming aura of Transmutation
38-
magic.
39-
4038
*/
4139

40+
// Casting 'Arcane Sight' reveals an overwhelming aura of Transmutation
41+
// magic.
42+
4243
use cast;
4344
use libc;
4445
use prelude::*;

0 commit comments

Comments
 (0)