Stabilize {slice,array}::from_ref

This commit is contained in:
Maybe Waffle
2022-05-24 22:33:31 +04:00
parent b2eba058e6
commit 7a09b8a7b5
2 changed files with 2 additions and 2 deletions

View File

@@ -92,7 +92,7 @@ where
/// Converts a reference to `T` into a 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_shared", since = "1.63.0")]
pub const fn from_ref<T>(s: &T) -> &[T; 1] {
// SAFETY: Converting `&T` to `&[T; 1]` is sound.
unsafe { &*(s as *const T).cast::<[T; 1]>() }