mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-23 23:34:48 +00:00
Make MaybeUninit::zeroed
const
This commit is contained in:
parent
f7fd79ac1d
commit
2a5a6680fc
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user