pub struct Out<'a, T>where
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> Out<'a, T>where
T: ?Sized,
impl<'a, T> Out<'a, T>where
T: ?Sized,
Source§impl<'a, T> Out<'a, T>
impl<'a, T> Out<'a, T>
Sourcepub fn from_uninit(data: &'a mut MaybeUninit<T>) -> Out<'a, T>
pub fn from_uninit(data: &'a mut MaybeUninit<T>) -> Out<'a, T>
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]) -> Out<'a, [T]>where
T: Copy,
pub fn from_slice(slice: &'a mut [T]) -> Out<'a, [T]>where
T: Copy,
Forms an Out<'a, [T]>
.
Sourcepub fn from_uninit_slice(slice: &'a mut [MaybeUninit<T>]) -> Out<'a, [T]>
pub fn from_uninit_slice(slice: &'a mut [MaybeUninit<T>]) -> Out<'a, [T]>
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.