Added get_mut and get_ref into the nightly as well

This commit is contained in:
Emil Fresk 2019-08-09 14:57:12 +02:00
parent 7de26409c2
commit 2e3a889991

View file

@ -82,21 +82,19 @@ impl<T> MaybeUninit<T> {
self.inner.as_mut_ptr() self.inner.as_mut_ptr()
} }
#[cfg(feature = "nightly")]
pub fn write(&mut self, value: T) -> &mut T {
self.inner.write(value)
}
#[cfg(not(feature = "nightly"))]
pub unsafe fn get_ref(&self) -> &T { pub unsafe fn get_ref(&self) -> &T {
&*self.inner.as_ptr() &*self.inner.as_ptr()
} }
#[cfg(not(feature = "nightly"))]
pub unsafe fn get_mut(&mut self) -> &mut T { pub unsafe fn get_mut(&mut self) -> &mut T {
&mut *self.inner.as_mut_ptr() &mut *self.inner.as_mut_ptr()
} }
#[cfg(feature = "nightly")]
pub fn write(&mut self, value: T) -> &mut T {
self.inner.write(value)
}
#[cfg(not(feature = "nightly"))] #[cfg(not(feature = "nightly"))]
pub fn write(&mut self, value: T) -> &mut T { pub fn write(&mut self, value: T) -> &mut T {
self.inner = core::mem::MaybeUninit::new(value); self.inner = core::mem::MaybeUninit::new(value);