Skip to content

Commit

Permalink
Rollup merge of rust-lang#45340 - stjepang:localkey-state-doc-skip-un…
Browse files Browse the repository at this point in the history
…initialized, r=alexcrichton

Docs: a LocalKey might start in the Valid state

Add a comment to the docs for `LocalKey::state` explaining that some keys might skip the `Uninitialized` state and start in the `Valid` state.

cc rust-lang#27716

r? @alexcrichton
  • Loading branch information
kennytm authored Oct 18, 2017
2 parents c77068a + a50fe31 commit c6892f4
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/libstd/thread/local.rs
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,10 @@ impl<T: 'static> LocalKey<T> {
///
/// Once the initialization expression succeeds, the key transitions to the
/// `Valid` state which will guarantee that future calls to [`with`] will
/// succeed within the thread.
/// succeed within the thread. Some keys might skip the `Uninitialized`
/// state altogether and start in the `Valid` state as an optimization
/// (e.g. keys initialized with a constant expression), but no guarantees
/// are made.
///
/// When a thread exits, each key will be destroyed in turn, and as keys are
/// destroyed they will enter the `Destroyed` state just before the
Expand Down

0 comments on commit c6892f4

Please sign in to comment.