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

View File

@ -1816,6 +1816,8 @@ impl<T: ?Sized + fmt::Display> fmt::Display for RefMut<'_, T> {
///
/// [`.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