diff --git a/library/core/src/array/mod.rs b/library/core/src/array/mod.rs index 9e42ab5923aa0..bbeec9fc17351 100644 --- a/library/core/src/array/mod.rs +++ b/library/core/src/array/mod.rs @@ -12,7 +12,8 @@ use crate::hash::{self, Hash}; use crate::iter::TrustedLen; use crate::mem::{self, MaybeUninit}; use crate::ops::{ - ChangeOutputType, ControlFlow, FromResidual, Index, IndexMut, NeverShortCircuit, Residual, Try, + ChangeOutputType, ControlFlow, Deref, DerefMut, FromResidual, Index, IndexMut, + NeverShortCircuit, Residual, Try, }; use crate::slice::{Iter, IterMut}; @@ -175,6 +176,24 @@ impl const BorrowMut<[T]> for [T; N] { } } +#[stable(feature = "array_deref", since = "1.61.0")] +#[rustc_const_unstable(feature = "const_array_deref", issue = "none")] +impl const Deref for [T; N] { + type Target = [T]; + + fn deref(&self) -> &[T] { + self as &[T] + } +} + +#[stable(feature = "array_deref", since = "1.61.0")] +#[rustc_const_unstable(feature = "const_array_deref", issue = "none")] +impl const DerefMut for [T; N] { + fn deref_mut(&mut self) -> &mut [T] { + self as &mut [T] + } +} + #[stable(feature = "try_from", since = "1.34.0")] impl TryFrom<&[T]> for [T; N] where