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 new<T>(ptr: *mut T) -> OpaqueUninit<'mem>
pub fn new<T>(ptr: *mut T) -> OpaqueUninit<'mem>
Create a new opaque pointer from a mutable pointer
Sourcepub fn from_maybe_uninit<T>(
borrow: &'mem mut MaybeUninit<T>,
) -> OpaqueUninit<'mem>
pub fn from_maybe_uninit<T>( borrow: &'mem mut MaybeUninit<T>, ) -> OpaqueUninit<'mem>
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>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more