-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Add MaybeUninit::new #55252
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add MaybeUninit::new #55252
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1021,6 +1021,15 @@ pub union MaybeUninit<T> { | |
} | ||
|
||
impl<T> MaybeUninit<T> { | ||
/// Create a new `MaybeUninit` initialized with the given value. | ||
/// | ||
/// Note that dropping a `MaybeUninit` will never call `T`'s drop code. | ||
/// It is your responsibility to make sure `T` gets dropped if it got initialized. | ||
#[unstable(feature = "maybe_uninit", issue = "53491")] | ||
pub const fn new(val: T) -> MaybeUninit<T> { | ||
MaybeUninit { value: ManuallyDrop::new(val) } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should this be spelled Edit: Sorry for spam during the GitHub outage. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If we do this as |
||
} | ||
|
||
/// Create a new `MaybeUninit` in an uninitialized state. | ||
/// | ||
/// Note that dropping a `MaybeUninit` will never call `T`'s drop code. | ||
|
Uh oh!
There was an error while loading. Please reload this page.