File tree Expand file tree Collapse file tree 2 files changed +10
-0
lines changed Expand file tree Collapse file tree 2 files changed +10
-0
lines changed Original file line number Diff line number Diff line change 8282#![ feature( const_fn) ]
8383#![ feature( const_int_ops) ]
8484#![ feature( const_fn_union) ]
85+ #![ feature( const_manually_drop_new) ]
8586#![ feature( custom_attribute) ]
8687#![ feature( doc_cfg) ]
8788#![ feature( doc_spotlight) ]
Original file line number Diff line number Diff line change @@ -1021,6 +1021,15 @@ pub union MaybeUninit<T> {
10211021}
10221022
10231023impl < T > MaybeUninit < T > {
1024+ /// Create a new `MaybeUninit` initialized with the given value.
1025+ ///
1026+ /// Note that dropping a `MaybeUninit` will never call `T`'s drop code.
1027+ /// It is your responsibility to make sure `T` gets dropped if it got initialized.
1028+ #[ unstable( feature = "maybe_uninit" , issue = "53491" ) ]
1029+ pub const fn new ( val : T ) -> MaybeUninit < T > {
1030+ MaybeUninit { value : ManuallyDrop :: new ( val) }
1031+ }
1032+
10241033 /// Create a new `MaybeUninit` in an uninitialized state.
10251034 ///
10261035 /// Note that dropping a `MaybeUninit` will never call `T`'s drop code.
You can’t perform that action at this time.
0 commit comments