1
0
mirror of https://github.com/google/comprehensive-rust.git synced 2025-07-03 21:39:51 +02:00

Split interior mutability, mention OnceCell/OnceLock (#2573)

These types are really only useful as a static or in a user-defined
type, neither of which are covered at this point.
This commit is contained in:
Dustin J. Mitchell
2025-01-20 12:48:02 -05:00
committed by GitHub
parent 5f7e0c3f64
commit 8121e7de7c
5 changed files with 81 additions and 68 deletions

View File

@ -34,6 +34,9 @@ Interior mutability is possible through a
[`Mutex`](https://doc.rust-lang.org/std/sync/struct.Mutex.html), atomic or
similar.
It is common to use `OnceLock` in a static as a way to support initialization on
first use. `OnceCell` is not `Sync` and thus cannot be used in this context.
Thread-local data can be created with the macro `std::thread_local`.
</details>