pub struct OpaqueUninit<'mem>(/* private fields */);Expand description
A type-erased pointer to an uninitialized value
Implementations§
Source§impl<'mem> OpaqueUninit<'mem>
impl<'mem> OpaqueUninit<'mem>
Sourcepub fn from_maybe_uninit<T>(borrow: &'mem mut MaybeUninit<T>) -> Self
pub fn from_maybe_uninit<T>(borrow: &'mem mut MaybeUninit<T>) -> Self
Creates a new opaque pointer from a reference to a MaybeUninit
The pointer will point to the potentially uninitialized contents
Sourcepub unsafe fn assume_init(self) -> Opaque<'mem>
pub unsafe fn assume_init(self) -> Opaque<'mem>
Assumes the pointer is initialized and returns an Opaque pointer
§Safety
The pointer must actually be pointing to initialized memory of the correct type.
Sourcepub unsafe fn write<T>(self, value: T) -> Opaque<'mem>
pub unsafe fn write<T>(self, value: T) -> Opaque<'mem>
Write a value to this location and convert to an initialized pointer
§Safety
The pointer must be properly aligned for T and point to allocated memory that can be safely written to.
Sourcepub fn as_mut_ptr(self) -> *mut u8
pub fn as_mut_ptr(self) -> *mut u8
Returns the underlying raw pointer as a byte pointer
Sourcepub unsafe fn field_uninit(self, offset: usize) -> OpaqueUninit<'mem>
pub unsafe fn field_uninit(self, offset: usize) -> OpaqueUninit<'mem>
Returns a pointer with the given offset added
§Safety
Offset is within the bounds of the allocated memory
Sourcepub unsafe fn field_init(self, offset: usize) -> Opaque<'mem>
pub unsafe fn field_init(self, offset: usize) -> Opaque<'mem>
Returns a pointer with the given offset added, assuming it’s initialized
§Safety
The pointer plus offset must be:
- Within bounds of the allocated object
- Properly aligned for the type being pointed to
- Point to initialized data of the correct type
Trait Implementations§
Source§impl<'mem> Clone for OpaqueUninit<'mem>
impl<'mem> Clone for OpaqueUninit<'mem>
Source§fn clone(&self) -> OpaqueUninit<'mem>
fn clone(&self) -> OpaqueUninit<'mem>
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreimpl<'mem> Copy for OpaqueUninit<'mem>
Auto Trait Implementations§
impl<'mem> Freeze for OpaqueUninit<'mem>
impl<'mem> RefUnwindSafe for OpaqueUninit<'mem>
impl<'mem> !Send for OpaqueUninit<'mem>
impl<'mem> !Sync for OpaqueUninit<'mem>
impl<'mem> Unpin for OpaqueUninit<'mem>
impl<'mem> !UnwindSafe for OpaqueUninit<'mem>
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