stabilize {slice,array}::from_mut

This commit is contained in:
ultrabear
2024-09-18 19:16:28 -07:00
parent 883f9a2c8f
commit 461b49d96d
4 changed files with 4 additions and 6 deletions

View File

@@ -146,7 +146,8 @@ pub const fn from_ref<T>(s: &T) -> &[T; 1] {
/// Converts a mutable reference to `T` into a mutable reference to an array of length 1 (without copying).
#[stable(feature = "array_from_ref", since = "1.53.0")]
#[rustc_const_unstable(feature = "const_array_from_ref", issue = "90206")]
#[rustc_const_stable(feature = "const_array_from_ref", since = "CURRENT_RUSTC_VERSION")]
#[cfg_attr(bootstrap, rustc_allow_const_fn_unstable(const_mut_refs))]
pub const fn from_mut<T>(s: &mut T) -> &mut [T; 1] {
// SAFETY: Converting `&mut T` to `&mut [T; 1]` is sound.
unsafe { &mut *(s as *mut T).cast::<[T; 1]>() }