about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--src/libcore/mem.rs5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/libcore/mem.rs b/src/libcore/mem.rs
index 3348e774a0b..4712df1fa7c 100644
--- a/src/libcore/mem.rs
+++ b/src/libcore/mem.rs
@@ -1117,11 +1117,14 @@ impl<T> MaybeUninit<T> {
     }
 
     /// Set the value of the `MaybeUninit`. This overwrites any previous value without dropping it.
+    /// For your convenience, this also returns a mutable reference to the (now
+    /// safely initialized) content of `self`.
     #[unstable(feature = "maybe_uninit", issue = "53491")]
     #[inline(always)]
-    pub fn set(&mut self, val: T) {
+    pub fn set(&mut self, val: T) -> &mut T {
         unsafe {
             self.value = ManuallyDrop::new(val);
+            self.get_mut()
         }
     }