Skip to content

Commit

Permalink
Add From<Box<[A]>> for 1-D owned arrays
Browse files Browse the repository at this point in the history
  • Loading branch information
jturner314 committed May 30, 2021
1 parent e7600e8 commit be5f603
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/arraytraits.rs
Expand Up @@ -148,6 +148,18 @@ where
{
}

impl<A, S> From<Box<[A]>> for ArrayBase<S, Ix1>
where
S: DataOwned<Elem = A>,
{
/// Create a one-dimensional array from a boxed slice (no copying needed).
///
/// **Panics** if the length is greater than `isize::MAX`.
fn from(b: Box<[A]>) -> Self {
Self::from_vec(b.into_vec())
}
}

impl<A, S> From<Vec<A>> for ArrayBase<S, Ix1>
where
S: DataOwned<Elem = A>,
Expand Down

0 comments on commit be5f603

Please sign in to comment.