Skip to content

Commit

Permalink
hybrid-array: simplify From<Array<T, U>> impl for [T; N] (#1011)
Browse files Browse the repository at this point in the history
If the latter is named specifically as an associated type, then it can
simply be moved out of the `Array` newtype.
  • Loading branch information
tarcieri committed Dec 31, 2023
1 parent fc5d614 commit 6e3a1eb
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions hybrid-array/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -351,12 +351,11 @@ where
impl<T, U, const N: usize> From<Array<T, U>> for [T; N]
where
Array<T, U>: ArrayOps<T, N>,
U: ArraySize,
U: ArraySize<ArrayType<T> = [T; N]>,
{
#[inline]
fn from(arr: Array<T, U>) -> [T; N] {
let mut items = arr.0.into_iter();
core::array::from_fn(|_| items.next().expect("should always have item"))
arr.0
}
}

Expand Down

0 comments on commit 6e3a1eb

Please sign in to comment.