Rollup merge of #44396 - joshlf:tls-comment, r=alexcrichton
std:🧵:LocalKey: Document limitation with initializers
Document that if a `LocalKey`'s initializer recursively depends on itself, initialization will result in infinite recursion.
This commit is contained in:
commit
f76f2c76dc
1 changed files with 4 additions and 0 deletions
|
@ -31,6 +31,10 @@ use mem;
|
||||||
/// within a thread, and values that implement [`Drop`] get destructed when a
|
/// within a thread, and values that implement [`Drop`] get destructed when a
|
||||||
/// thread exits. Some caveats apply, which are explained below.
|
/// thread exits. Some caveats apply, which are explained below.
|
||||||
///
|
///
|
||||||
|
/// A `LocalKey`'s initializer cannot recursively depend on itself, and using
|
||||||
|
/// a `LocalKey` in this way will cause the initializer to infinitely recurse
|
||||||
|
/// on the first call to `with`.
|
||||||
|
///
|
||||||
/// # Examples
|
/// # Examples
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue