@@ -813,8 +813,9 @@ impl<T> MaybeUninit<T> {
813
813
///
814
814
/// [`assume_init_ref`]: MaybeUninit::assume_init_ref
815
815
#[ unstable( feature = "maybe_uninit_slice" , issue = "63569" ) ]
816
+ #[ rustc_const_unstable( feature = "const_maybe_assume_init" , issue = "none" ) ]
816
817
#[ inline( always) ]
817
- pub unsafe fn slice_assume_init_ref ( slice : & [ Self ] ) -> & [ T ] {
818
+ pub const unsafe fn slice_assume_init_ref ( slice : & [ Self ] ) -> & [ T ] {
818
819
// SAFETY: casting slice to a `*const [T]` is safe since the caller guarantees that
819
820
// `slice` is initialized, and`MaybeUninit` is guaranteed to have the same layout as `T`.
820
821
// The pointer obtained is valid since it refers to memory owned by `slice` which is a
@@ -834,24 +835,27 @@ impl<T> MaybeUninit<T> {
834
835
///
835
836
/// [`assume_init_mut`]: MaybeUninit::assume_init_mut
836
837
#[ unstable( feature = "maybe_uninit_slice" , issue = "63569" ) ]
838
+ #[ rustc_const_unstable( feature = "const_maybe_assume_init" , issue = "none" ) ]
837
839
#[ inline( always) ]
838
- pub unsafe fn slice_assume_init_mut ( slice : & mut [ Self ] ) -> & mut [ T ] {
840
+ pub const unsafe fn slice_assume_init_mut ( slice : & mut [ Self ] ) -> & mut [ T ] {
839
841
// SAFETY: similar to safety notes for `slice_get_ref`, but we have a
840
842
// mutable reference which is also guaranteed to be valid for writes.
841
843
unsafe { & mut * ( slice as * mut [ Self ] as * mut [ T ] ) }
842
844
}
843
845
844
846
/// Gets a pointer to the first element of the array.
845
847
#[ unstable( feature = "maybe_uninit_slice" , issue = "63569" ) ]
848
+ #[ rustc_const_unstable( feature = "const_maybe_assume_init" , issue = "none" ) ]
846
849
#[ inline( always) ]
847
- pub fn slice_as_ptr ( this : & [ MaybeUninit < T > ] ) -> * const T {
850
+ pub const fn slice_as_ptr ( this : & [ MaybeUninit < T > ] ) -> * const T {
848
851
this. as_ptr ( ) as * const T
849
852
}
850
853
851
854
/// Gets a mutable pointer to the first element of the array.
852
855
#[ unstable( feature = "maybe_uninit_slice" , issue = "63569" ) ]
856
+ #[ rustc_const_unstable( feature = "const_maybe_assume_init" , issue = "none" ) ]
853
857
#[ inline( always) ]
854
- pub fn slice_as_mut_ptr ( this : & mut [ MaybeUninit < T > ] ) -> * mut T {
858
+ pub const fn slice_as_mut_ptr ( this : & mut [ MaybeUninit < T > ] ) -> * mut T {
855
859
this. as_mut_ptr ( ) as * mut T
856
860
}
857
861
}
0 commit comments