pub struct PtrUninit { /* private fields */ }Expand description
A type-erased pointer to uninitialized memory.
Wraps PtrMut but represents uninitialized memory. No lifetime parameter.
Implementations§
Source§impl PtrUninit
impl PtrUninit
Sourcepub fn new<T>(ptr: *mut T) -> PtrUninitwhere
T: ?Sized,
pub fn new<T>(ptr: *mut T) -> PtrUninitwhere
T: ?Sized,
Create a new uninit pointer from a mutable pointer.
Sourcepub const fn new_sized<T>(ptr: *mut T) -> PtrUninit
pub const fn new_sized<T>(ptr: *mut T) -> PtrUninit
Create a new uninit pointer from a pointer to a sized type. This is const because sized types use thin pointers.
Sourcepub fn from_maybe_uninit<T>(borrow: &mut MaybeUninit<T>) -> PtrUninit
pub fn from_maybe_uninit<T>(borrow: &mut MaybeUninit<T>) -> PtrUninit
Creates from a reference to a MaybeUninit.
Sourcepub fn as_mut_byte_ptr(self) -> *mut u8
pub fn as_mut_byte_ptr(self) -> *mut u8
Returns the underlying raw pointer as a mutable byte pointer.
§Panics
Panics if this is a wide pointer.
Sourcepub fn as_byte_ptr(self) -> *const u8
pub fn as_byte_ptr(self) -> *const u8
Returns the underlying raw pointer as a const byte pointer.
§Panics
Panics if this is a wide pointer.
Sourcepub const unsafe fn assume_init(self) -> PtrMut
pub const unsafe fn assume_init(self) -> PtrMut
Assumes the pointer is initialized and returns a PtrMut.
§Safety
The memory must actually be initialized.
Sourcepub unsafe fn put<T>(self, value: T) -> PtrMut
pub unsafe fn put<T>(self, value: T) -> PtrMut
Write a value to this location and return an initialized pointer.
§Safety
The pointer must be properly aligned and point to allocated memory.
Sourcepub unsafe fn copy_from(
self,
src: PtrConst,
shape: &'static Shape,
) -> Result<PtrMut, UnsizedError>
pub unsafe fn copy_from( self, src: PtrConst, shape: &'static Shape, ) -> Result<PtrMut, UnsizedError>
Copies memory from a source pointer into this location.
§Safety
- The source pointer must be valid for reads
- This pointer must be valid for writes and properly aligned
- The regions may not overlap
Sourcepub unsafe fn field_uninit(self, offset: usize) -> PtrUninit
pub unsafe fn field_uninit(self, offset: usize) -> PtrUninit
Returns a pointer with the given offset added (still uninit).
§Safety
Offset must be within bounds of the allocated memory.
Sourcepub unsafe fn field_init(self, offset: usize) -> PtrMut
pub unsafe fn field_init(self, offset: usize) -> PtrMut
Returns a pointer with the given offset added, assuming it’s initialized.
§Safety
- Offset must be within bounds
- The memory at that offset must be initialized
Trait Implementations§
impl Copy for PtrUninit
impl Eq for PtrUninit
impl StructuralPartialEq for PtrUninit
Auto Trait Implementations§
impl Freeze for PtrUninit
impl RefUnwindSafe for PtrUninit
impl !Send for PtrUninit
impl !Sync for PtrUninit
impl Unpin for PtrUninit
impl UnsafeUnpin for PtrUninit
impl UnwindSafe for PtrUninit
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.