mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-27 17:24:06 +00:00
stabilize core::array::{from_ref,from_mut}
This commit is contained in:
parent
010c2368fa
commit
740b0529fb
@ -23,14 +23,14 @@ mod iter;
|
||||
pub use iter::IntoIter;
|
||||
|
||||
/// Converts a reference to `T` into a reference to an array of length 1 (without copying).
|
||||
#[unstable(feature = "array_from_ref", issue = "77101")]
|
||||
#[stable(feature = "array_from_ref", since = "1.53.0")]
|
||||
pub fn from_ref<T>(s: &T) -> &[T; 1] {
|
||||
// SAFETY: Converting `&T` to `&[T; 1]` is sound.
|
||||
unsafe { &*(s as *const T).cast::<[T; 1]>() }
|
||||
}
|
||||
|
||||
/// Converts a mutable reference to `T` into a mutable reference to an array of length 1 (without copying).
|
||||
#[unstable(feature = "array_from_ref", issue = "77101")]
|
||||
#[stable(feature = "array_from_ref", since = "1.53.0")]
|
||||
pub 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]>() }
|
||||
|
@ -1,6 +1,5 @@
|
||||
#![feature(alloc_layout_extra)]
|
||||
#![feature(array_chunks)]
|
||||
#![feature(array_from_ref)]
|
||||
#![feature(array_methods)]
|
||||
#![feature(array_map)]
|
||||
#![feature(array_windows)]
|
||||
|
Loading…
Reference in New Issue
Block a user