@@ -910,52 +910,6 @@ impl<T> MaybeUninit<T> {
910910 }
911911 }
912912
913- /// Extracts the values from an array of `MaybeUninit` containers.
914- ///
915- /// # Safety
916- ///
917- /// It is up to the caller to guarantee that all elements of the array are
918- /// in an initialized state.
919- ///
920- /// # Examples
921- ///
922- /// ```
923- /// #![feature(maybe_uninit_uninit_array)]
924- /// #![feature(maybe_uninit_array_assume_init)]
925- /// use std::mem::MaybeUninit;
926- ///
927- /// let mut array: [MaybeUninit<i32>; 3] = MaybeUninit::uninit_array();
928- /// array[0].write(0);
929- /// array[1].write(1);
930- /// array[2].write(2);
931- ///
932- /// // SAFETY: Now safe as we initialised all elements
933- /// let array = unsafe {
934- /// MaybeUninit::array_assume_init(array)
935- /// };
936- ///
937- /// assert_eq!(array, [0, 1, 2]);
938- /// ```
939- #[ unstable( feature = "maybe_uninit_array_assume_init" , issue = "96097" ) ]
940- #[ rustc_const_unstable( feature = "const_maybe_uninit_array_assume_init" , issue = "96097" ) ]
941- #[ inline( always) ]
942- #[ track_caller]
943- pub const unsafe fn array_assume_init < const N : usize > ( array : [ Self ; N ] ) -> [ T ; N ] {
944- // SAFETY:
945- // * The caller guarantees that all elements of the array are initialized
946- // * `MaybeUninit<T>` and T are guaranteed to have the same layout
947- // * `MaybeUninit` does not drop, so there are no double-frees
948- // And thus the conversion is safe
949- let ret = unsafe {
950- intrinsics:: assert_inhabited :: < [ T ; N ] > ( ) ;
951- ( & array as * const _ as * const [ T ; N ] ) . read ( )
952- } ;
953-
954- // FIXME: required to avoid `~const Destruct` bound
955- super :: forget ( array) ;
956- ret
957- }
958-
959913 /// Assuming all the elements are initialized, get a slice to them.
960914 ///
961915 /// # Safety
0 commit comments