Make MaybeUninit::zeroed const

This commit is contained in:
woppopo 2021-12-13 14:17:35 +09:00
parent f7fd79ac1d
commit 2a5a6680fc

View File

@ -394,10 +394,11 @@ impl<T> MaybeUninit<T> {
/// // This is undefined behavior. ⚠️
/// ```
#[stable(feature = "maybe_uninit", since = "1.36.0")]
#[rustc_const_unstable(feature = "const_maybe_uninit_zeroed", issue = "91850")]
#[must_use]
#[inline]
#[rustc_diagnostic_item = "maybe_uninit_zeroed"]
pub fn zeroed() -> MaybeUninit<T> {
pub const fn zeroed() -> MaybeUninit<T> {
let mut u = MaybeUninit::<T>::uninit();
// SAFETY: `u.as_mut_ptr()` points to allocated memory.
unsafe {