outref

Struct Out

Source
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:

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>

Source

pub unsafe fn new(data: *mut T) -> Self

Forms an Out<'a, T>

§Safety
  • data must be valid for writes.
  • data must be properly aligned.
Source

pub unsafe fn assume_init(self) -> &'a mut T

Converts to a mutable (unique) reference to the value.

§Safety

The referenced value must be initialized when calling this function.

Source

pub fn reborrow<'s>(&'s mut self) -> Out<'s, T>
where 'a: 's,

Reborrows the out reference for a shorter lifetime.

Source§

impl<'a, T> Out<'a, T>

Source

pub fn from_mut(data: &'a mut T) -> Self
where T: Copy,

Forms an Out<'a, T>.

Source

pub fn from_uninit(data: &'a mut MaybeUninit<T>) -> Self

Forms an Out<'a, T> from an uninitialized value.

Source

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.

Source

pub fn as_mut_ptr(&mut self) -> *mut T

Returns an unsafe mutable pointer to the value.

Source§

impl<'a, T> Out<'a, [T]>

Source

pub fn from_slice(slice: &'a mut [T]) -> Self
where T: Copy,

Forms an Out<'a, [T]>.

Source

pub fn from_uninit_slice(slice: &'a mut [MaybeUninit<T>]) -> Self

Forms an Out<'a, [T]> from an uninitialized slice.

Source

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.

Source

pub const fn is_empty(&self) -> bool

Returns true if the slice has a length of 0.

Source

pub const fn len(&self) -> usize

Returns the number of elements in the slice.

Source

pub fn as_mut_ptr(&mut self) -> *mut T

Returns an unsafe mutable pointer to the slice’s buffer.

Trait Implementations§

Source§

impl<T: Send> Send for Out<'_, T>

Source§

impl<T: Sync> Sync for Out<'_, T>

Source§

impl<T: Unpin> Unpin for Out<'_, T>

Auto Trait Implementations§

§

impl<'a, T> Freeze for Out<'a, T>
where T: ?Sized,

§

impl<'a, T> RefUnwindSafe for Out<'a, T>
where T: RefUnwindSafe + ?Sized,

§

impl<'a, T> !UnwindSafe for Out<'a, T>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.