diff --git a/src/lib.rs b/src/lib.rs index fd8c59c..d015036 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -217,6 +217,22 @@ where } } +impl Array, U> +where + U: ArraySize, +{ + /// Create an uninitialized array of [`MaybeUninit`]s for the given type. + pub unsafe fn uninit() -> Self { + MaybeUninit::uninit().assume_init() + } + + /// Create an uninitialized array of [`MaybeUninit`]s for the given type. + pub unsafe fn assume_init(self) -> Array { + // TODO(tarcieri): use `MaybeUninit::array_assume_init` when stable + ptr::read(self.as_ptr().cast()) + } +} + impl AsRef<[T]> for Array where U: ArraySize,