pub struct Out<'a, T: 'a + ?Sized> { /* private fields */ }
Expand description
Out reference (&'a out T
).
An out reference is similar to a mutable reference, but it may point to uninitialized memory. An out reference may be used to initialize the pointee or represent a data buffer.
&'a out T
can be converted from:
&'a mut MaybeUninit<T>
and&'a mut [MaybeUninit<T>]
, where theT
may be uninitialized.&'a mut T
and&'a mut [T]
, where theT
is initialized and Copy.
It is not allowed to corrupt or de-initialize the pointee, which may cause unsoundness.
It is the main difference between &'a out T
and &'a mut MaybeUninit<T>
/&'a mut [MaybeUninit<T>]
.
Any reads through an out reference may read uninitialized value(s).
Implementations§
source§impl<'a, T: ?Sized> Out<'a, T>
impl<'a, T: ?Sized> Out<'a, T>
source§impl<'a, T> Out<'a, T>
impl<'a, T> Out<'a, T>
sourcepub fn from_mut(data: &'a mut T) -> Selfwhere
T: Copy,
pub fn from_mut(data: &'a mut T) -> Selfwhere
T: Copy,
Forms an Out<'a, T>
.
sourcepub fn from_uninit(data: &'a mut MaybeUninit<T>) -> Self
pub fn from_uninit(data: &'a mut MaybeUninit<T>) -> Self
Forms an Out<'a, T>
from an uninitialized value.
sourcepub unsafe fn into_uninit(self) -> &'a mut MaybeUninit<T>
pub unsafe fn into_uninit(self) -> &'a mut MaybeUninit<T>
Converts to &'a mut MaybeUninit<T>
§Safety
It is not allowed to corrupt or de-initialize the pointee.
sourcepub fn as_mut_ptr(&mut self) -> *mut T
pub fn as_mut_ptr(&mut self) -> *mut T
Returns an unsafe mutable pointer to the value.
source§impl<'a, T> Out<'a, [T]>
impl<'a, T> Out<'a, [T]>
sourcepub fn from_slice(slice: &'a mut [T]) -> Selfwhere
T: Copy,
pub fn from_slice(slice: &'a mut [T]) -> Selfwhere
T: Copy,
Forms an Out<'a, [T]>
.
sourcepub fn from_uninit_slice(slice: &'a mut [MaybeUninit<T>]) -> Self
pub fn from_uninit_slice(slice: &'a mut [MaybeUninit<T>]) -> Self
Forms an Out<'a, [T]>
from an uninitialized slice.
sourcepub unsafe fn into_uninit_slice(self) -> &'a mut [MaybeUninit<T>]
pub unsafe fn into_uninit_slice(self) -> &'a mut [MaybeUninit<T>]
Converts to &'a mut [MaybeUninit<T>]
§Safety
It is not allowed to corrupt or de-initialize the pointee.
sourcepub fn as_mut_ptr(&mut self) -> *mut T
pub fn as_mut_ptr(&mut self) -> *mut T
Returns an unsafe mutable pointer to the slice’s buffer.