]> git.lizzy.rs Git - rust.git/commitdiff
Docs: a LocalKey might start in the Valid state
authorStjepan Glavina <stjepang@gmail.com>
Tue, 17 Oct 2017 09:02:25 +0000 (11:02 +0200)
committerStjepan Glavina <stjepang@gmail.com>
Tue, 17 Oct 2017 09:02:25 +0000 (11:02 +0200)
src/libstd/thread/local.rs

index a53c76a333a99dbc576ec72411c5da6433ea3df1..cb18eed8ee54b63e6eb8ce493c2a35075d7e03cd 100644 (file)
@@ -325,7 +325,10 @@ unsafe fn init(&self, slot: &UnsafeCell<Option<T>>) -> &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