mirror of
https://github.com/rust-lang/rust.git
synced 2025-06-22 12:37:32 +00:00
add comment explaining why what we do is legal
This commit is contained in:
parent
41434e001b
commit
25d46f3091
@ -1509,6 +1509,8 @@ impl<T: ?Sized> UnsafeCell<T> {
|
||||
#[inline]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
pub const fn get(&self) -> *mut T {
|
||||
// We can just cast the pointer from `UnsafeCell<T>` to `T` because of
|
||||
// #[repr(transparent)]
|
||||
self as *const UnsafeCell<T> as *const T as *mut T
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user