Skip to content

Commit

Permalink
Stabilize UnsafeCell::from_mut
Browse files Browse the repository at this point in the history
  • Loading branch information
clarfonthey committed Oct 4, 2024
1 parent 267cf8d commit 874aee7
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion library/core/src/cell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2125,7 +2125,8 @@ 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")]
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>) }
Expand Down

0 comments on commit 874aee7

Please sign in to comment.