rust-lang/rust — pull request #19094 by alexcrichton (2014-11-18 23:18:21+00:00)
Title: std: Add a new top-level tls module

This commit removes the `std::local_data` module in favor of a new `std::tls`
module providing thread local storage. The module provides two variants of TLS:
one which owns its contents and one which is based on scoped references. Each
implementation has pros and cons listed in the documentation.

Both flavors have accessors through a function called `with` which yield a
reference to a closure provided. Both flavors also panic if a reference cannot
be yielded and provide a function to test whether an access would panic or not.
This is an implementation of [RFC 461][rfc] and full details can be found in
that RFC.

This is a breaking change due to the removal of the `std::local_data` module.
All users can migrate to the new tls system like so:

tls!(static FOO: Rc>> = Rc::new(RefCell::new(None)))

The old `local_data` module inherently contained the `Rc>>` as
an implementation detail which must now be explicitly stated by users.

[rfc]: https://github.com/rust-lang/rfcs/pull/461
[breaking-change]