about summary refs log tree commit diff
diff options
context:
space:
mode:
authorAlbin Hedman <albin9604@gmail.com>2020-12-08 00:07:34 +0100
committerAlbin Hedman <albin9604@gmail.com>2020-12-08 00:07:34 +0100
commit077527170bd112d97bdbb288ae8771930bcaa5b7 (patch)
tree8cd35587b4c94b753c2bef48b0a16fd20e3e594f
parent174935988f131efcbce3c63924ee056940c36fb5 (diff)
downloadrust-077527170bd112d97bdbb288ae8771930bcaa5b7.tar.gz
rust-077527170bd112d97bdbb288ae8771930bcaa5b7.zip
Make write and slice_as_[mut_]_ptr const
-rw-r--r--library/core/src/mem/maybe_uninit.rs9
1 files changed, 6 insertions, 3 deletions
diff --git a/library/core/src/mem/maybe_uninit.rs b/library/core/src/mem/maybe_uninit.rs
index 57ebab33188..8800d7714cf 100644
--- a/library/core/src/mem/maybe_uninit.rs
+++ b/library/core/src/mem/maybe_uninit.rs
@@ -373,8 +373,9 @@ impl<T> MaybeUninit<T> {
     /// skip running the destructor. For your convenience, this also returns a mutable
     /// reference to the (now safely initialized) contents of `self`.
     #[unstable(feature = "maybe_uninit_extra", issue = "63567")]
+    #[rustc_const_unstable(feature = "maybe_uninit_extra", issue = "63567")]
     #[inline(always)]
-    pub fn write(&mut self, val: T) -> &mut T {
+    pub const fn write(&mut self, val: T) -> &mut T {
         *self = MaybeUninit::new(val);
         // SAFETY: We just initialized this value.
         unsafe { self.assume_init_mut() }
@@ -846,15 +847,17 @@ impl<T> MaybeUninit<T> {
 
     /// Gets a pointer to the first element of the array.
     #[unstable(feature = "maybe_uninit_slice", issue = "63569")]
+    #[rustc_const_unstable(feature = "maybe_uninit_slice", issue = "63569")]
     #[inline(always)]
-    pub fn slice_as_ptr(this: &[MaybeUninit<T>]) -> *const T {
+    pub const fn slice_as_ptr(this: &[MaybeUninit<T>]) -> *const T {
         this.as_ptr() as *const T
     }
 
     /// Gets a mutable pointer to the first element of the array.
     #[unstable(feature = "maybe_uninit_slice", issue = "63569")]
+    #[rustc_const_unstable(feature = "maybe_uninit_slice", issue = "63569")]
     #[inline(always)]
-    pub fn slice_as_mut_ptr(this: &mut [MaybeUninit<T>]) -> *mut T {
+    pub const fn slice_as_mut_ptr(this: &mut [MaybeUninit<T>]) -> *mut T {
         this.as_mut_ptr() as *mut T
     }
 }