Skip to content

Commit 0775271

Browse files
committed
Make write and slice_as_[mut_]_ptr const
1 parent 1749359 commit 0775271

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

library/core/src/mem/maybe_uninit.rs

+6-3
Original file line numberDiff line numberDiff line change
@@ -373,8 +373,9 @@ impl<T> MaybeUninit<T> {
373373
/// skip running the destructor. For your convenience, this also returns a mutable
374374
/// reference to the (now safely initialized) contents of `self`.
375375
#[unstable(feature = "maybe_uninit_extra", issue = "63567")]
376+
#[rustc_const_unstable(feature = "maybe_uninit_extra", issue = "63567")]
376377
#[inline(always)]
377-
pub fn write(&mut self, val: T) -> &mut T {
378+
pub const fn write(&mut self, val: T) -> &mut T {
378379
*self = MaybeUninit::new(val);
379380
// SAFETY: We just initialized this value.
380381
unsafe { self.assume_init_mut() }
@@ -846,15 +847,17 @@ impl<T> MaybeUninit<T> {
846847

847848
/// Gets a pointer to the first element of the array.
848849
#[unstable(feature = "maybe_uninit_slice", issue = "63569")]
850+
#[rustc_const_unstable(feature = "maybe_uninit_slice", issue = "63569")]
849851
#[inline(always)]
850-
pub fn slice_as_ptr(this: &[MaybeUninit<T>]) -> *const T {
852+
pub const fn slice_as_ptr(this: &[MaybeUninit<T>]) -> *const T {
851853
this.as_ptr() as *const T
852854
}
853855

854856
/// Gets a mutable pointer to the first element of the array.
855857
#[unstable(feature = "maybe_uninit_slice", issue = "63569")]
858+
#[rustc_const_unstable(feature = "maybe_uninit_slice", issue = "63569")]
856859
#[inline(always)]
857-
pub fn slice_as_mut_ptr(this: &mut [MaybeUninit<T>]) -> *mut T {
860+
pub const fn slice_as_mut_ptr(this: &mut [MaybeUninit<T>]) -> *mut T {
858861
this.as_mut_ptr() as *mut T
859862
}
860863
}

0 commit comments

Comments
 (0)