rust/library/core
Matthias Krüger b90277e37b
Rollup merge of #106921 - madsmtm:cell-memory-layout, r=dtolnay
Add documentation about the memory layout of `Cell`

https://github.com/rust-lang/rust/pull/101717 guaranteed the memory layout of `UnsafeCell<T>`.

This property (a guaranteed memory layout) can be useful to have on `Cell<T>` as well.

(Note that `Cell<u8>` [already doesn't trigger the `improper_ctypes` lint](https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=34af59ef60b96d8a8bdaec1d52cb5420) since it is `#[repr(transparent)]`).

The concrete use-case is for the crate [`objc2`](https://github.com/madsmtm/objc2) to specify that `Cell<T>` is safe to use as an instance variable when `T` is.

Fixes https://github.com/rust-lang/rust/issues/79303.

---

I'm unsure if we should specify less, for example say that the `Cell` may have extra restrictions on when it may be accessed, or if that's implicit in the (deliberately minimal) way I've worded it here?
2023-03-10 19:59:17 +01:00
..
benches Auto merge of #108157 - scottmcm:tuple-gt-via-partialcmp, r=dtolnay 2023-03-05 22:02:26 +00:00
primitive_docs Add primitive documentation to libcore 2021-09-12 02:23:08 +00:00
src Rollup merge of #106921 - madsmtm:cell-memory-layout, r=dtolnay 2023-03-10 19:59:17 +01:00
tests Match unmatched backticks in library/ 2023-03-03 03:03:29 +01:00
Cargo.toml Update rand in the stdlib tests, and remove the getrandom feature from it 2023-01-04 14:52:41 -08:00