Added a panic-on-uninhabited guard on get_ref and get_mut
This commit is contained in:
parent
2ebf5e6e2f
commit
d9087cb388
1 changed files with 2 additions and 0 deletions
|
@ -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
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue