Skip to content

Commit f8c7d8d

Browse files
committed
make set return a mutable reference
1 parent 760424a commit f8c7d8d

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/libcore/mem.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1117,11 +1117,14 @@ impl<T> MaybeUninit<T> {
11171117
}
11181118

11191119
/// Set the value of the `MaybeUninit`. This overwrites any previous value without dropping it.
1120+
/// For your convenience, this also returns a mutable reference to the (now
1121+
/// safely initialized) content of `self`.
11201122
#[unstable(feature = "maybe_uninit", issue = "53491")]
11211123
#[inline(always)]
1122-
pub fn set(&mut self, val: T) {
1124+
pub fn set(&mut self, val: T) -> &mut T {
11231125
unsafe {
11241126
self.value = ManuallyDrop::new(val);
1127+
self.get_mut()
11251128
}
11261129
}
11271130

0 commit comments

Comments
 (0)