Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions src/libstd/local_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@ anywhere within a task, keyed by a global pointer parameterized over the type of
the TLS slot. Useful for dynamic variables, singletons, and interfacing with
foreign code with bad callback interfaces.

To use, declare a static variable of the type you wish to store. The
initialization should be `&local_data::Key`. This is then the key to what you
wish to store.
To declare a new key for storing local data of a particular type, use the
`local_data_key!` macro. This macro will expand to a `static` item apppriately
named and annotated. This name is then passed to the functions in this module to
modify/read the slot specified by the key.

~~~{.rust}
use std::local_data;
Expand All @@ -31,14 +32,14 @@ local_data::set(key_int, 3);
local_data::get(key_int, |opt| assert_eq!(opt, Some(&3)));

local_data::set(key_vector, ~[4]);
local_data::get(key_int, |opt| assert_eq!(opt, Some(&~[4])));
local_data::get(key_vector, |opt| assert_eq!(opt, Some(&~[4])));
~~~

Casting 'Arcane Sight' reveals an overwhelming aura of Transmutation
magic.

*/

// Casting 'Arcane Sight' reveals an overwhelming aura of Transmutation
// magic.

use cast;
use libc;
use prelude::*;
Expand Down