make things ugly
This commit is contained in:
parent
5b5ae01340
commit
861698a493
1 changed files with 3 additions and 3 deletions
|
@ -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
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue