Added a panic-on-uninhabited guard on get_ref and get_mut

This commit is contained in:
Daniel Henry-Mantilla 2019-10-30 14:52:56 +01:00
parent 2ebf5e6e2f
commit d9087cb388

View file

@ -571,6 +571,7 @@ impl<T> MaybeUninit<T> {
#[unstable(feature = "maybe_uninit_ref", issue = "63568")]
#[inline(always)]
pub unsafe fn get_ref(&self) -> &T {
intrinsics::panic_if_uninhabited::<T>();
&*self.value
}
@ -690,6 +691,7 @@ impl<T> MaybeUninit<T> {
#[unstable(feature = "maybe_uninit_ref", issue = "63568")]
#[inline(always)]
pub unsafe fn get_mut(&mut self) -> &mut T {
intrinsics::panic_if_uninhabited::<T>();
&mut *self.value
}