From 0f15056e9dd7b74e905dac5cda4cb5f3098599bb Mon Sep 17 00:00:00 2001 From: Jim Turner Date: Sun, 30 May 2021 00:36:44 -0400 Subject: [PATCH] Add From> for 1-D owned arrays --- src/arraytraits.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/arraytraits.rs b/src/arraytraits.rs index 421fc4713..07a82e2b7 100644 --- a/src/arraytraits.rs +++ b/src/arraytraits.rs @@ -11,6 +11,7 @@ use std::iter::FromIterator; use std::iter::IntoIterator; use std::mem; use std::ops::{Index, IndexMut}; +use alloc::boxed::Box; use alloc::vec::Vec; use crate::imp_prelude::*; @@ -148,6 +149,18 @@ where { } +impl From> for ArrayBase +where + S: DataOwned, +{ + /// 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 From> for ArrayBase where S: DataOwned,