Skip to content

Commit 46b67ab

Browse files
authored
Rollup merge of #84105 - WaffleLapkin:stabilize_array_from_ref, r=m-ou-se
stabilize `core::array::{from_ref,from_mut}` in `1.53.0` I didn't get any response in #77101 (comment), so I figured out I can try opening stabilization pr. --- This PR stabilizes following functions: ```rust // core::array pub fn from_ref<T>(s: &T) -> &[T; 1]; pub fn from_mut<T>(s: &mut T) -> &mut [T; 1]; ``` Functions are similar to already stabilized `core::slice::{`[`from_ref`](https://doc.rust-lang.org/std/slice/fn.from_ref.html),[`from_mut`](https://doc.rust-lang.org/std/slice/fn.from_mut.html)`}` and were unstable without any problems/questions for a while now. --- resolves #77101 ``@rustbot`` modify labels: +T-libs
2 parents e109aa3 + 740b052 commit 46b67ab

File tree

2 files changed

+2
-3
lines changed

2 files changed

+2
-3
lines changed

library/core/src/array/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,14 @@ mod iter;
2222
pub use iter::IntoIter;
2323

2424
/// Converts a reference to `T` into a reference to an array of length 1 (without copying).
25-
#[unstable(feature = "array_from_ref", issue = "77101")]
25+
#[stable(feature = "array_from_ref", since = "1.53.0")]
2626
pub fn from_ref<T>(s: &T) -> &[T; 1] {
2727
// SAFETY: Converting `&T` to `&[T; 1]` is sound.
2828
unsafe { &*(s as *const T).cast::<[T; 1]>() }
2929
}
3030

3131
/// Converts a mutable reference to `T` into a mutable reference to an array of length 1 (without copying).
32-
#[unstable(feature = "array_from_ref", issue = "77101")]
32+
#[stable(feature = "array_from_ref", since = "1.53.0")]
3333
pub fn from_mut<T>(s: &mut T) -> &mut [T; 1] {
3434
// SAFETY: Converting `&mut T` to `&mut [T; 1]` is sound.
3535
unsafe { &mut *(s as *mut T).cast::<[T; 1]>() }

library/core/tests/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
#![feature(alloc_layout_extra)]
22
#![feature(array_chunks)]
3-
#![feature(array_from_ref)]
43
#![feature(array_methods)]
54
#![feature(array_map)]
65
#![feature(array_windows)]

0 commit comments

Comments
 (0)