Skip to content

Commit

Permalink
Match core's definition of uninit_array
Browse files Browse the repository at this point in the history
Since we specifically bound on `ArrayType = [T; N]` it's possible to
write that directly.

Using the exact same code as core should help ensure and inspire
confidence that it's implemented correctly.

Note: a TODO still suggests using the upstream `core` method when it's
been stabilized
  • Loading branch information
tarcieri committed Jan 14, 2024
1 parent 5510e29 commit de1a85e
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ where
// See how `core` defines `MaybeUninit::uninit_array` for a similar example:
// <https://github.com/rust-lang/rust/blob/917f654/library/core/src/mem/maybe_uninit.rs#L350-L352>
// TODO(tarcieri): use `MaybeUninit::uninit_array` when stable
Self(unsafe { MaybeUninit::<U::ArrayType<MaybeUninit<T>>>::uninit().assume_init() })
Self(unsafe { MaybeUninit::<[MaybeUninit<T>; N]>::uninit().assume_init() })
}

/// Extract the values from an array of `MaybeUninit` containers.
Expand Down

0 comments on commit de1a85e

Please sign in to comment.