Function new

Source
pub unsafe fn new<T, const N: usize>(
    initial: &T,
) -> Result<Box<[T; N]>, LayoutError>
where T: Clone,
Expand description

Allocates [T; N] on the heap and initializes its entries to initial.

For now, this function uses the global allocator. This will change once the Allocator trait becomes stable.

§Safety

The result of this function is undefined if mem::size_of::<T>() == 0, or if N == 0

§Errors

See Layout::array