Skip to content

Commit a50fe31

Browse files
author
Stjepan Glavina
committed
Docs: a LocalKey might start in the Valid state
1 parent 2d75213 commit a50fe31

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/libstd/thread/local.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,10 @@ impl<T: 'static> LocalKey<T> {
325325
///
326326
/// Once the initialization expression succeeds, the key transitions to the
327327
/// `Valid` state which will guarantee that future calls to [`with`] will
328-
/// succeed within the thread.
328+
/// succeed within the thread. Some keys might skip the `Uninitialized`
329+
/// state altogether and start in the `Valid` state as an optimization
330+
/// (e.g. keys initialized with a constant expression), but no guarantees
331+
/// are made.
329332
///
330333
/// When a thread exits, each key will be destroyed in turn, and as keys are
331334
/// destroyed they will enter the `Destroyed` state just before the

0 commit comments

Comments
 (0)