-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Add MaybeUninit::new #55252
Conversation
Sometimes it *is* initialized!
r? @bluss (rust_highfive has picked a reviewer for you, use r? to override) |
/// 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 comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be spelled From::from
? (Additionally/instead/never, I don't know.)
Edit: Sorry for spam during the GitHub outage.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we do this as From
now, then it cannot be const fn for the time being (but hopefully in the future...).
Memo from T-lang to T-libs: Since the stabilization of See:
|
@bors r+ rollup |
📌 Commit ac18635 has been approved by |
Add MaybeUninit::new Sometimes it *is* initialized!
Add MaybeUninit::new Sometimes it *is* initialized!
Rollup of 11 pull requests Successful merges: - #55148 (Implement FromStr for PathBuf) - #55185 (path suggestions in Rust 2018 should point out the change in semantics) - #55191 (Fix sub-variant doc display) - #55199 (Impl items have generics) - #55244 (Don't rerun MIR passes when inlining) - #55252 (Add MaybeUninit::new) - #55257 (Allow extern statics with an extern type) - #55389 (Remove unnecessary mut in iterator.find_map documentation example, R…) - #55406 (Update string.rs) - #55412 (Fix an ICE in the min_const_fn analysis) - #55421 (Add ManuallyDrop::take)
Sometimes it is initialized!