1
0
mirror of https://github.com/google/comprehensive-rust.git synced 2025-07-02 05:04:29 +02:00

Add note about !Sync (#2138)

This is key to the validity of how Cell and RefCell allow safe interior
mutability.
This commit is contained in:
Andrew Walbran
2024-06-10 15:35:13 +01:00
committed by GitHub
parent c45b291851
commit 26e1d77b3e

View File

@ -71,4 +71,8 @@ that safety, and `RefCell` and `Cell` are two of them.
`&self`. This needs no runtime check, but requires moving values, which can
have its own cost.
- Both `RefCell` and `Cell` are `!Sync`, which means `&RefCell` and `&Cell`
can't be passed between threads. This prevents two threads trying to access
the cell at once.
</details>