diff options
| author | Ralf Jung <post@ralfj.de> | 2019-02-03 22:14:14 +0100 |
|---|---|---|
| committer | Ralf Jung <post@ralfj.de> | 2019-02-03 22:14:14 +0100 |
| commit | f8c7d8dc8e8f779e6468e83f79456ed1916a93d7 (patch) | |
| tree | 7347b23c2d9d9af69d33af12e1bb23abae1d398a /src/libcore | |
| parent | 760424af17bc40c4fd2be95e96ebcebe70d217e9 (diff) | |
| download | rust-f8c7d8dc8e8f779e6468e83f79456ed1916a93d7.tar.gz rust-f8c7d8dc8e8f779e6468e83f79456ed1916a93d7.zip | |
make set return a mutable reference
Diffstat (limited to 'src/libcore')
| -rw-r--r-- | src/libcore/mem.rs | 5 |
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() } } |
