Rollup merge of #91086 - rhysd:issue-91085, r=m-ou-se

Implement `TryFrom<&'_ mut [T]>` for `[T; N]`

Fixes #91085.
This commit is contained in:
Matthias Krüger
2021-12-13 00:20:06 +01:00
committed by GitHub
2 changed files with 24 additions and 1 deletions

View File

@@ -189,6 +189,18 @@ where
}
}
#[stable(feature = "try_from_mut_slice_to_array", since = "1.59.0")]
impl<T, const N: usize> TryFrom<&mut [T]> for [T; N]
where
T: Copy,
{
type Error = TryFromSliceError;
fn try_from(slice: &mut [T]) -> Result<[T; N], TryFromSliceError> {
<Self>::try_from(&*slice)
}
}
#[stable(feature = "try_from", since = "1.34.0")]
impl<'a, T, const N: usize> TryFrom<&'a [T]> for &'a [T; N] {
type Error = TryFromSliceError;