use crate::{Array, Box, Boxed, Vec, init_array};
impl<T, const CAP: usize> Array<T, CAP, Boxed> {
pub fn new_boxed(boxed_array: Box<[T; CAP]>) -> Self {
Array { data: boxed_array }
}
pub fn with_cloned(element: T) -> Self
where
T: Clone,
{
let data = init_array!(clone_heap [T; CAP], "safe_data", "unsafe_array", element);
Self { data }
}
}
impl<T, const CAP: usize> Array<T, CAP, Boxed> {
#[must_use]
pub fn into_array(self) -> Box<[T; CAP]> {
self.data
}
#[must_use]
pub fn into_slice(self) -> Box<[T]> {
self.data
}
#[must_use]
pub fn into_vec(self) -> Vec<T> {
self.into_slice().into_vec()
}
}