1
Fork 0

make things ugly

This commit is contained in:
Ralf Jung 2019-11-13 09:31:08 +01:00
parent 5b5ae01340
commit 861698a493

View file

@ -1572,18 +1572,18 @@ impl<T: ?Sized> UnsafeCell<T> {
/// use std::mem::MaybeUninit;
///
/// let m = MaybeUninit::<UnsafeCell<i32>>::uninit();
/// unsafe { m.as_ptr().raw_get().write(5); }
/// unsafe { UnsafeCell::raw_get(m.as_ptr()).write(5); }
/// let uc = unsafe { m.assume_init() };
///
/// assert_eq!(uc.into_inner(), 5);
/// ```
#[inline]
#[unstable(feature = "unsafe_cell_raw_get", issue = "66358")]
pub const fn raw_get(self: *const Self) -> *mut T {
pub const fn raw_get(this: *const Self) -> *mut T {
// We can just cast the pointer from `UnsafeCell<T>` to `T` because of
// #[repr(transparent)]. This exploits libstd's special status, there is
// no guarantee for user code that this will work in future versions of the compiler!
self as *const T as *mut T
this as *const T as *mut T
}
}