Function new_default

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

Allocates [T; N] on the heap and initializes its entries to T::default().

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