Skip to content

Commit

Permalink
hybrid-array: simpler TryFrom impl (#1015)
Browse files Browse the repository at this point in the history
  • Loading branch information
tarcieri authored Dec 31, 2023
1 parent 8a81f1d commit a15a4aa
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions hybrid-array/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ where
// #[deprecated(since = "0.2.0", note = "use TryFrom instead")]
pub fn from_slice(slice: &[T]) -> Result<Self, TryFromSliceError>
where
T: Copy,
Self: Copy,
{
slice.try_into()
}
Expand Down Expand Up @@ -491,15 +491,14 @@ where

impl<'a, T, U> TryFrom<&'a [T]> for Array<T, U>
where
T: Copy,
Self: Copy,
U: ArraySize,
{
type Error = TryFromSliceError;

#[inline]
fn try_from(slice: &'a [T]) -> Result<Array<T, U>, TryFromSliceError> {
check_slice_length::<T, U>(slice)?;
Ok(Self::from_fn(|n| slice[n]))
<&'a Self>::try_from(slice).map(|ret| *ret)
}
}

Expand Down

0 comments on commit a15a4aa

Please sign in to comment.