pub struct MaybeCopy<T> { /* private fields */ }Expand description
Equivalent to an UnsafeCell<MaybeUninit<T>>, this cell may hold uninitialized data.
Unlike Maybe<T> this structure is suited for data types with no Drop implementation.
Implementations§
Source§impl<T: Copy> MaybeCopy<T>
impl<T: Copy> MaybeCopy<T>
Sourcepub unsafe fn as_mut_ptr(&mut self) -> *mut T
pub unsafe fn as_mut_ptr(&mut self) -> *mut T
Access the contained value as a mutable pointer.
Sourcepub unsafe fn as_ref(&self) -> &T
pub unsafe fn as_ref(&self) -> &T
Obtain a reference to the contained value. This method is unsafe because
the value may not have been initialized.
Sourcepub fn set_loaded(&self, loaded: bool)
pub fn set_loaded(&self, loaded: bool)
Override the loaded flag of the cell. This method is a no-op when using the
unchecked implementation. It may be used when a value is inserted manually,
for example by assigning to the dereferenced pointer.
Trait Implementations§
Auto Trait Implementations§
impl<T> !Freeze for MaybeCopy<T>
impl<T> !RefUnwindSafe for MaybeCopy<T>
impl<T> Send for MaybeCopy<T>where
T: Send,
impl<T> !Sync for MaybeCopy<T>
impl<T> Unpin for MaybeCopy<T>where
T: Unpin,
impl<T> UnwindSafe for MaybeCopy<T>where
T: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more