|
|
|
|
|
by oneshtein
498 days ago
|
|
> you can’t have references to uninitialized memory. The method is available[0] in nightly Rust pub const unsafe fn as_uninit_ref<'a>(self) -> Option<&'a MaybeUninit<T>>
where
T: Sized,
{
// SAFETY: the caller must guarantee that `self` meets all the
// requirements for a reference.
if self.is_null() { None } else { Some(unsafe { &*(self as *const MaybeUninit<T>) }) }
}
[0]: https://doc.rust-lang.org/stable/core/primitive.pointer.html... |
|