diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2021-12-13 00:20:06 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-12-13 00:20:06 +0100 |
| commit | 42f8d4833f21030fa3dff509a2559dfcb5d5ed72 (patch) | |
| tree | 7411b533a153c8dd227a934da58dece33941298e /library/core/src/array | |
| parent | 6bda5b331cfe7e04e1fe348c58a928fc2b650f4f (diff) | |
| parent | 16711fe0768d9df5daf73a2025913984ea17f8eb (diff) | |
| download | rust-42f8d4833f21030fa3dff509a2559dfcb5d5ed72.tar.gz rust-42f8d4833f21030fa3dff509a2559dfcb5d5ed72.zip | |
Rollup merge of #91086 - rhysd:issue-91085, r=m-ou-se
Implement `TryFrom<&'_ mut [T]>` for `[T; N]` Fixes #91085.
Diffstat (limited to 'library/core/src/array')
| -rw-r--r-- | library/core/src/array/mod.rs | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/library/core/src/array/mod.rs b/library/core/src/array/mod.rs index 0e33e95271e..37292bf8e26 100644 --- a/library/core/src/array/mod.rs +++ b/library/core/src/array/mod.rs @@ -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; |
