Stabilize UnsafeCell::from_mut
This commit is contained in:
parent
267cf8d3b2
commit
6828a1edc6
@ -2115,7 +2115,6 @@ impl<T: ?Sized> UnsafeCell<T> {
|
||||
/// # Examples
|
||||
///
|
||||
/// ```
|
||||
/// # #![feature(unsafe_cell_from_mut)]
|
||||
/// use std::cell::UnsafeCell;
|
||||
///
|
||||
/// let mut val = 42;
|
||||
@ -2125,7 +2124,9 @@ impl<T: ?Sized> UnsafeCell<T> {
|
||||
/// assert_eq!(*uc.get_mut(), 41);
|
||||
/// ```
|
||||
#[inline(always)]
|
||||
#[unstable(feature = "unsafe_cell_from_mut", issue = "111645")]
|
||||
#[stable(feature = "unsafe_cell_from_mut", since = "CURRENT_RUSTC_VERSION")]
|
||||
#[rustc_const_stable(feature = "unsafe_cell_from_mut", since = "CURRENT_RUSTC_VERSION")]
|
||||
#[cfg_attr(bootstrap, rustc_allow_const_fn_unstable(const_mut_refs))]
|
||||
pub const fn from_mut(value: &mut T) -> &mut UnsafeCell<T> {
|
||||
// SAFETY: `UnsafeCell<T>` has the same memory layout as `T` due to #[repr(transparent)].
|
||||
unsafe { &mut *(value as *mut T as *mut UnsafeCell<T>) }
|
||||
|
Loading…
Reference in New Issue
Block a user