Struct outref::Out

source ·
#[repr(transparent)]
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§

Forms an Out<'a, T>

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

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

Safety

The referenced value must be initialized when calling this function.

Reborrows the out reference for a shorter lifetime.

Forms an Out<'a, T>.

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

Converts to &'a mut MaybeUninit<T>

Safety

It is not allowed to corrupt or de-initialize the pointee.

Returns an unsafe mutable pointer to the value.

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

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

Converts to &'a mut [MaybeUninit<T>]

Safety

It is not allowed to corrupt or de-initialize the pointee.

Returns true if the slice has a length of 0.

Returns the number of elements in the slice.

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

Trait Implementations§

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.