From a15a4aad0d3feedb7f71556f53c0611db3de916c Mon Sep 17 00:00:00 2001 From: Tony Arcieri Date: Sat, 30 Dec 2023 18:16:55 -0700 Subject: [PATCH] hybrid-array: simpler `TryFrom` impl (#1015) --- hybrid-array/src/lib.rs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/hybrid-array/src/lib.rs b/hybrid-array/src/lib.rs index 887ca255..3478f3b4 100644 --- a/hybrid-array/src/lib.rs +++ b/hybrid-array/src/lib.rs @@ -72,7 +72,7 @@ where // #[deprecated(since = "0.2.0", note = "use TryFrom instead")] pub fn from_slice(slice: &[T]) -> Result where - T: Copy, + Self: Copy, { slice.try_into() } @@ -491,15 +491,14 @@ where impl<'a, T, U> TryFrom<&'a [T]> for Array where - T: Copy, + Self: Copy, U: ArraySize, { type Error = TryFromSliceError; #[inline] fn try_from(slice: &'a [T]) -> Result, TryFromSliceError> { - check_slice_length::(slice)?; - Ok(Self::from_fn(|n| slice[n])) + <&'a Self>::try_from(slice).map(|ret| *ret) } }