add "Memory layout" subsection to documentation of UnsafeCell for additional clarity

This commit is contained in:
Pointerbender
2022-10-27 06:32:36 +02:00
parent 5673536153
commit 166d8b8c2b
+2
View File
@@ -1816,6 +1816,8 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
///
/// [`.get_mut()`]: `UnsafeCell::get_mut`
///
/// # Memory layout
///
/// `UnsafeCell<T>` has the same in-memory representation as its inner type `T`. A consequence
/// of this guarantee is that it is possible to convert between `T` and `UnsafeCell<T>`.
/// Special care has to be taken when converting a nested `T` inside of an `Outer<T>` type