pub trait AsOut<Pointee: ?Sized> {
    // Required method
    fn as_out<'out>(&'out mut self) -> Out<'out, Pointee>;
}
Expand description

Extension trait to convert a &mut _ into a &out _ by calling .as_out() on it.

By autoref, this means that you can even just extract a &out T reference out of a mut element simply by calling .as_out() on it.

There is, however, one restriction: to be able to call .as_out() on something, it needs to be either Copy, or a value wrapped in a MaybeUninit / a ManuallyDrop.

This is by design. Indeed, Out references do not call the destructor of the overwritten element (since it may not be initialized). This could cause memory leaks when there is an initialized element with drop glue.

To solve this limitation, one must explicitly call .manually_drop_mut() to automagically transmute the &mut _ reference into a &mut ManuallyDrop<_>.

Examples

use ::uninit::prelude::*;

let mut x = 0;
x.as_out().write(42);

let mut y = ::core::mem::MaybeUninit::uninit();
y.as_out().write(42);
let y = unsafe { y.assume_init() };

assert_eq!(x, y);

Required Methods§

source

fn as_out<'out>(&'out mut self) -> Out<'out, Pointee>

Implementations on Foreign Types§

source§

impl<T> AsOut<[T]> for [MaybeUninit<T>; 1024]

source§

fn as_out<'out>(&'out mut self) -> Out<'out, [T]>

source§

impl<T> AsOut<[T]> for [MaybeUninit<T>; 53]

source§

fn as_out<'out>(&'out mut self) -> Out<'out, [T]>

source§

impl<T> AsOut<[T]> for [T; 32]where T: Copy,

source§

fn as_out<'out>(&'out mut self) -> Out<'out, [T]>

source§

impl<T> AsOut<[T]> for [MaybeUninit<T>; 512]

source§

fn as_out<'out>(&'out mut self) -> Out<'out, [T]>

source§

impl<T> AsOut<[T]> for [T; 1]where T: Copy,

source§

fn as_out<'out>(&'out mut self) -> Out<'out, [T]>

source§

impl<T> AsOut<[T]> for [T; 42]where T: Copy,

source§

fn as_out<'out>(&'out mut self) -> Out<'out, [T]>

source§

impl<T> AsOut<[T]> for [T; 50]where T: Copy,

source§

fn as_out<'out>(&'out mut self) -> Out<'out, [T]>

source§

impl<T> AsOut<[T]> for [MaybeUninit<T>; 9]

source§

fn as_out<'out>(&'out mut self) -> Out<'out, [T]>

source§

impl<T> AsOut<[T]> for [MaybeUninit<T>; 1]

source§

fn as_out<'out>(&'out mut self) -> Out<'out, [T]>

source§

impl<T> AsOut<[T]> for [T; 59]where T: Copy,

source§

fn as_out<'out>(&'out mut self) -> Out<'out, [T]>

source§

impl<T> AsOut<[T]> for [T; 57]where T: Copy,

source§

fn as_out<'out>(&'out mut self) -> Out<'out, [T]>

source§

impl<T> AsOut<[T]> for [T; 36]where T: Copy,

source§

fn as_out<'out>(&'out mut self) -> Out<'out, [T]>

source§

impl<T> AsOut<[T]> for [T; 62]where T: Copy,

source§

fn as_out<'out>(&'out mut self) -> Out<'out, [T]>

source§

impl<T> AsOut<[T]> for [T; 11]where T: Copy,

source§

fn as_out<'out>(&'out mut self) -> Out<'out, [T]>

source§

impl<T> AsOut<[T]> for [T; 3]where T: Copy,

source§

fn as_out<'out>(&'out mut self) -> Out<'out, [T]>

source§

impl<T> AsOut<[T]> for [MaybeUninit<T>; 37]

source§

fn as_out<'out>(&'out mut self) -> Out<'out, [T]>

source§

impl<T> AsOut<[T]> for [T; 44]where T: Copy,

source§

fn as_out<'out>(&'out mut self) -> Out<'out, [T]>

source§

impl<T> AsOut<[T]> for [T; 13]where T: Copy,

source§

fn as_out<'out>(&'out mut self) -> Out<'out, [T]>

source§

impl<T> AsOut<[T]> for [MaybeUninit<T>; 54]

source§

fn as_out<'out>(&'out mut self) -> Out<'out, [T]>

source§

impl<T> AsOut<[T]> for [MaybeUninit<T>; 24]

source§

fn as_out<'out>(&'out mut self) -> Out<'out, [T]>

source§

impl<T> AsOut<[T]> for [T; 12]where T: Copy,

source§

fn as_out<'out>(&'out mut self) -> Out<'out, [T]>

source§

impl<T> AsOut<[T]> for [T; 64]where T: Copy,

source§

fn as_out<'out>(&'out mut self) -> Out<'out, [T]>

source§

impl<T> AsOut<[T]> for [T; 512]where T: Copy,

source§

fn as_out<'out>(&'out mut self) -> Out<'out, [T]>

source§

impl<T> AsOut<[T]> for [MaybeUninit<T>; 55]

source§

fn as_out<'out>(&'out mut self) -> Out<'out, [T]>

source§

impl<T> AsOut<T> for ManuallyDrop<T>

source§

fn as_out<'out>(self: &'out mut ManuallyDrop<T>) -> Out<'out, T>

source§

impl<T> AsOut<[T]> for [T; 30]where T: Copy,

source§

fn as_out<'out>(&'out mut self) -> Out<'out, [T]>

source§

impl<T> AsOut<[T]> for [T; 24]where T: Copy,

source§

fn as_out<'out>(&'out mut self) -> Out<'out, [T]>

source§

impl<T> AsOut<[T]> for [MaybeUninit<T>; 15]

source§

fn as_out<'out>(&'out mut self) -> Out<'out, [T]>

source§

impl<T> AsOut<[T]> for [MaybeUninit<T>; 36]

source§

fn as_out<'out>(&'out mut self) -> Out<'out, [T]>

source§

impl<T> AsOut<[T]> for [T; 17]where T: Copy,

source§

fn as_out<'out>(&'out mut self) -> Out<'out, [T]>

source§

impl<T> AsOut<[T]> for [T; 26]where T: Copy,

source§

fn as_out<'out>(&'out mut self) -> Out<'out, [T]>

source§

impl<T> AsOut<[T]> for [MaybeUninit<T>; 256]

source§

fn as_out<'out>(&'out mut self) -> Out<'out, [T]>

source§

impl<T> AsOut<[T]> for [MaybeUninit<T>; 41]

source§

fn as_out<'out>(&'out mut self) -> Out<'out, [T]>

source§

impl<T> AsOut<[T]> for [MaybeUninit<T>; 17]

source§

fn as_out<'out>(&'out mut self) -> Out<'out, [T]>

source§

impl<T> AsOut<[T]> for [MaybeUninit<T>; 6]

source§

fn as_out<'out>(&'out mut self) -> Out<'out, [T]>

source§

impl<T> AsOut<[T]> for [MaybeUninit<T>; 13]

source§

fn as_out<'out>(&'out mut self) -> Out<'out, [T]>

source§

impl<T> AsOut<[T]> for [T; 38]where T: Copy,

source§

fn as_out<'out>(&'out mut self) -> Out<'out, [T]>

source§

impl<T> AsOut<[T]> for [MaybeUninit<T>; 51]

source§

fn as_out<'out>(&'out mut self) -> Out<'out, [T]>

source§

impl<T> AsOut<[T]> for [T; 2]where T: Copy,

source§

fn as_out<'out>(&'out mut self) -> Out<'out, [T]>

source§

impl<T> AsOut<[T]> for [MaybeUninit<T>; 4]

source§

fn as_out<'out>(&'out mut self) -> Out<'out, [T]>

source§

impl<T> AsOut<[T]> for [T; 52]where T: Copy,

source§

fn as_out<'out>(&'out mut self) -> Out<'out, [T]>

source§

impl<T> AsOut<[T]> for [MaybeUninit<T>; 31]

source§

fn as_out<'out>(&'out mut self) -> Out<'out, [T]>

source§

impl<T> AsOut<[T]> for [MaybeUninit<T>; 56]

source§

fn as_out<'out>(&'out mut self) -> Out<'out, [T]>

source§

impl<T> AsOut<[T]> for [T; 25]where T: Copy,

source§

fn as_out<'out>(&'out mut self) -> Out<'out, [T]>

source§

impl<T> AsOut<[T]> for [T; 22]where T: Copy,

source§

fn as_out<'out>(&'out mut self) -> Out<'out, [T]>

source§

impl<T> AsOut<[T]> for [T; 47]where T: Copy,

source§

fn as_out<'out>(&'out mut self) -> Out<'out, [T]>

source§

impl<T> AsOut<[T]> for [T; 14]where T: Copy,

source§

fn as_out<'out>(&'out mut self) -> Out<'out, [T]>

source§

impl<T> AsOut<[T]> for [MaybeUninit<T>; 18]

source§

fn as_out<'out>(&'out mut self) -> Out<'out, [T]>

source§

impl<T> AsOut<[T]> for [MaybeUninit<T>; 45]

source§

fn as_out<'out>(&'out mut self) -> Out<'out, [T]>

source§

impl<T> AsOut<[T]> for [T; 5]where T: Copy,

source§

fn as_out<'out>(&'out mut self) -> Out<'out, [T]>

source§

impl<T> AsOut<[T]> for [MaybeUninit<T>; 21]

source§

fn as_out<'out>(&'out mut self) -> Out<'out, [T]>

source§

impl<T> AsOut<[T]> for [MaybeUninit<T>; 43]

source§

fn as_out<'out>(&'out mut self) -> Out<'out, [T]>

source§

impl<T> AsOut<[T]> for [T; 21]where T: Copy,

source§

fn as_out<'out>(&'out mut self) -> Out<'out, [T]>

source§

impl<T> AsOut<[T]> for [T; 46]where T: Copy,

source§

fn as_out<'out>(&'out mut self) -> Out<'out, [T]>

source§

impl<T> AsOut<[T]> for [MaybeUninit<T>; 60]

source§

fn as_out<'out>(&'out mut self) -> Out<'out, [T]>

source§

impl<T> AsOut<[T]> for [T; 35]where T: Copy,

source§

fn as_out<'out>(&'out mut self) -> Out<'out, [T]>

source§

impl<T> AsOut<[T]> for [T; 9]where T: Copy,

source§

fn as_out<'out>(&'out mut self) -> Out<'out, [T]>

source§

impl<T> AsOut<[T]> for [T; 28]where T: Copy,

source§

fn as_out<'out>(&'out mut self) -> Out<'out, [T]>

source§

impl<T> AsOut<[T]> for [MaybeUninit<T>]

source§

fn as_out<'out>(self: &'out mut [MaybeUninit<T>]) -> Out<'out, [T]>

source§

impl<T> AsOut<[T]> for [T]where T: Copy,

source§

fn as_out<'out>(self: &'out mut [T]) -> Out<'out, [T]>

source§

impl<T> AsOut<[T]> for [T; 55]where T: Copy,

source§

fn as_out<'out>(&'out mut self) -> Out<'out, [T]>

source§

impl<T> AsOut<[T]> for [MaybeUninit<T>; 40]

source§

fn as_out<'out>(&'out mut self) -> Out<'out, [T]>

source§

impl<T> AsOut<[T]> for [T; 19]where T: Copy,

source§

fn as_out<'out>(&'out mut self) -> Out<'out, [T]>

source§

impl<T> AsOut<[T]> for [MaybeUninit<T>; 5]

source§

fn as_out<'out>(&'out mut self) -> Out<'out, [T]>

source§

impl<T> AsOut<[T]> for [T; 56]where T: Copy,

source§

fn as_out<'out>(&'out mut self) -> Out<'out, [T]>

source§

impl<T> AsOut<[T]> for [MaybeUninit<T>; 0]

source§

fn as_out<'out>(&'out mut self) -> Out<'out, [T]>

source§

impl<T> AsOut<[T]> for [T; 27]where T: Copy,

source§

fn as_out<'out>(&'out mut self) -> Out<'out, [T]>

source§

impl<T> AsOut<[T]> for [MaybeUninit<T>; 64]

source§

fn as_out<'out>(&'out mut self) -> Out<'out, [T]>

source§

impl<T> AsOut<[T]> for [T; 18]where T: Copy,

source§

fn as_out<'out>(&'out mut self) -> Out<'out, [T]>

source§

impl<T> AsOut<[T]> for [T; 31]where T: Copy,

source§

fn as_out<'out>(&'out mut self) -> Out<'out, [T]>

source§

impl<T> AsOut<[T]> for [T; 40]where T: Copy,

source§

fn as_out<'out>(&'out mut self) -> Out<'out, [T]>

source§

impl<T> AsOut<[T]> for [T; 15]where T: Copy,

source§

fn as_out<'out>(&'out mut self) -> Out<'out, [T]>

source§

impl<T> AsOut<[T]> for [T; 51]where T: Copy,

source§

fn as_out<'out>(&'out mut self) -> Out<'out, [T]>

source§

impl<T> AsOut<[T]> for [MaybeUninit<T>; 42]

source§

fn as_out<'out>(&'out mut self) -> Out<'out, [T]>

source§

impl<T> AsOut<[T]> for [T; 128]where T: Copy,

source§

fn as_out<'out>(&'out mut self) -> Out<'out, [T]>

source§

impl<T> AsOut<[T]> for [MaybeUninit<T>; 46]

source§

fn as_out<'out>(&'out mut self) -> Out<'out, [T]>

source§

impl<T> AsOut<[T]> for [MaybeUninit<T>; 35]

source§

fn as_out<'out>(&'out mut self) -> Out<'out, [T]>

source§

impl<T> AsOut<[T]> for [MaybeUninit<T>; 14]

source§

fn as_out<'out>(&'out mut self) -> Out<'out, [T]>

source§

impl<T> AsOut<[T]> for [MaybeUninit<T>; 47]

source§

fn as_out<'out>(&'out mut self) -> Out<'out, [T]>

source§

impl<T> AsOut<[T]> for [T; 8]where T: Copy,

source§

fn as_out<'out>(&'out mut self) -> Out<'out, [T]>

source§

impl<T> AsOut<[T]> for [T; 45]where T: Copy,

source§

fn as_out<'out>(&'out mut self) -> Out<'out, [T]>

source§

impl<T> AsOut<[T]> for [T; 37]where T: Copy,

source§

fn as_out<'out>(&'out mut self) -> Out<'out, [T]>

source§

impl<T> AsOut<[T]> for [MaybeUninit<T>; 19]

source§

fn as_out<'out>(&'out mut self) -> Out<'out, [T]>

source§

impl<T> AsOut<[T]> for [T; 33]where T: Copy,

source§

fn as_out<'out>(&'out mut self) -> Out<'out, [T]>

source§

impl<T> AsOut<[T]> for [MaybeUninit<T>; 48]

source§

fn as_out<'out>(&'out mut self) -> Out<'out, [T]>

source§

impl<T> AsOut<[T]> for [T; 41]where T: Copy,

source§

fn as_out<'out>(&'out mut self) -> Out<'out, [T]>

source§

impl<T> AsOut<[T]> for [MaybeUninit<T>; 25]

source§

fn as_out<'out>(&'out mut self) -> Out<'out, [T]>

source§

impl<T> AsOut<[T]> for [T; 43]where T: Copy,

source§

fn as_out<'out>(&'out mut self) -> Out<'out, [T]>

source§

impl<T> AsOut<[T]> for [T; 58]where T: Copy,

source§

fn as_out<'out>(&'out mut self) -> Out<'out, [T]>

source§

impl<T> AsOut<[T]> for [T; 29]where T: Copy,

source§

fn as_out<'out>(&'out mut self) -> Out<'out, [T]>

source§

impl<T> AsOut<[T]> for [MaybeUninit<T>; 61]

source§

fn as_out<'out>(&'out mut self) -> Out<'out, [T]>

source§

impl<T> AsOut<[T]> for [MaybeUninit<T>; 52]

source§

fn as_out<'out>(&'out mut self) -> Out<'out, [T]>

source§

impl<T> AsOut<[T]> for [T; 0]where T: Copy,

source§

fn as_out<'out>(&'out mut self) -> Out<'out, [T]>

source§

impl<T> AsOut<[T]> for [MaybeUninit<T>; 28]

source§

fn as_out<'out>(&'out mut self) -> Out<'out, [T]>

source§

impl<T> AsOut<[T]> for [MaybeUninit<T>; 49]

source§

fn as_out<'out>(&'out mut self) -> Out<'out, [T]>

source§

impl<T> AsOut<[T]> for [MaybeUninit<T>; 44]

source§

fn as_out<'out>(&'out mut self) -> Out<'out, [T]>

source§

impl<T> AsOut<[T]> for [MaybeUninit<T>; 23]

source§

fn as_out<'out>(&'out mut self) -> Out<'out, [T]>

source§

impl<T> AsOut<[T]> for [T; 60]where T: Copy,

source§

fn as_out<'out>(&'out mut self) -> Out<'out, [T]>

source§

impl<T> AsOut<[T]> for [ManuallyDrop<T>]

source§

fn as_out<'out>(self: &'out mut [ManuallyDrop<T>]) -> Out<'out, [T]>

source§

impl<T> AsOut<[T]> for [MaybeUninit<T>; 29]

source§

fn as_out<'out>(&'out mut self) -> Out<'out, [T]>

source§

impl<T> AsOut<[T]> for [MaybeUninit<T>; 20]

source§

fn as_out<'out>(&'out mut self) -> Out<'out, [T]>

source§

impl<T> AsOut<[T]> for [MaybeUninit<T>; 30]

source§

fn as_out<'out>(&'out mut self) -> Out<'out, [T]>

source§

impl<T> AsOut<[T]> for [MaybeUninit<T>; 12]

source§

fn as_out<'out>(&'out mut self) -> Out<'out, [T]>

source§

impl<T> AsOut<[T]> for [T; 39]where T: Copy,

source§

fn as_out<'out>(&'out mut self) -> Out<'out, [T]>

source§

impl<T> AsOut<[T]> for [MaybeUninit<T>; 34]

source§

fn as_out<'out>(&'out mut self) -> Out<'out, [T]>

source§

impl<T> AsOut<[T]> for [MaybeUninit<T>; 50]

source§

fn as_out<'out>(&'out mut self) -> Out<'out, [T]>

source§

impl<T> AsOut<[T]> for [T; 53]where T: Copy,

source§

fn as_out<'out>(&'out mut self) -> Out<'out, [T]>

source§

impl<T> AsOut<[T]> for [T; 1024]where T: Copy,

source§

fn as_out<'out>(&'out mut self) -> Out<'out, [T]>

source§

impl<T> AsOut<[T]> for [MaybeUninit<T>; 33]

source§

fn as_out<'out>(&'out mut self) -> Out<'out, [T]>

source§

impl<T> AsOut<[T]> for [T; 10]where T: Copy,

source§

fn as_out<'out>(&'out mut self) -> Out<'out, [T]>

source§

impl<T> AsOut<[T]> for [MaybeUninit<T>; 16]

source§

fn as_out<'out>(&'out mut self) -> Out<'out, [T]>

source§

impl<T> AsOut<[T]> for [T; 16]where T: Copy,

source§

fn as_out<'out>(&'out mut self) -> Out<'out, [T]>

source§

impl<T> AsOut<[T]> for [MaybeUninit<T>; 128]

source§

fn as_out<'out>(&'out mut self) -> Out<'out, [T]>

source§

impl<T> AsOut<[T]> for [T; 63]where T: Copy,

source§

fn as_out<'out>(&'out mut self) -> Out<'out, [T]>

source§

impl<T> AsOut<[T]> for [T; 20]where T: Copy,

source§

fn as_out<'out>(&'out mut self) -> Out<'out, [T]>

source§

impl<T> AsOut<[T]> for [MaybeUninit<T>; 58]

source§

fn as_out<'out>(&'out mut self) -> Out<'out, [T]>

source§

impl<T> AsOut<[T]> for [MaybeUninit<T>; 59]

source§

fn as_out<'out>(&'out mut self) -> Out<'out, [T]>

source§

impl<T> AsOut<[T]> for [MaybeUninit<T>; 32]

source§

fn as_out<'out>(&'out mut self) -> Out<'out, [T]>

source§

impl<T> AsOut<[T]> for [T; 34]where T: Copy,

source§

fn as_out<'out>(&'out mut self) -> Out<'out, [T]>

source§

impl<T> AsOut<[T]> for [MaybeUninit<T>; 3]

source§

fn as_out<'out>(&'out mut self) -> Out<'out, [T]>

source§

impl<T> AsOut<[T]> for [MaybeUninit<T>; 63]

source§

fn as_out<'out>(&'out mut self) -> Out<'out, [T]>

source§

impl<T> AsOut<[T]> for [MaybeUninit<T>; 7]

source§

fn as_out<'out>(&'out mut self) -> Out<'out, [T]>

source§

impl<T> AsOut<[T]> for [MaybeUninit<T>; 2]

source§

fn as_out<'out>(&'out mut self) -> Out<'out, [T]>

source§

impl<T> AsOut<[T]> for [MaybeUninit<T>; 57]

source§

fn as_out<'out>(&'out mut self) -> Out<'out, [T]>

source§

impl<T> AsOut<[T]> for [MaybeUninit<T>; 22]

source§

fn as_out<'out>(&'out mut self) -> Out<'out, [T]>

source§

impl<T> AsOut<[T]> for [MaybeUninit<T>; 26]

source§

fn as_out<'out>(&'out mut self) -> Out<'out, [T]>

source§

impl<T> AsOut<[T]> for [MaybeUninit<T>; 10]

source§

fn as_out<'out>(&'out mut self) -> Out<'out, [T]>

source§

impl<T> AsOut<[T]> for [MaybeUninit<T>; 8]

source§

fn as_out<'out>(&'out mut self) -> Out<'out, [T]>

source§

impl<T> AsOut<[T]> for [T; 23]where T: Copy,

source§

fn as_out<'out>(&'out mut self) -> Out<'out, [T]>

source§

impl<T> AsOut<[T]> for [T; 256]where T: Copy,

source§

fn as_out<'out>(&'out mut self) -> Out<'out, [T]>

source§

impl<T> AsOut<[T]> for [T; 61]where T: Copy,

source§

fn as_out<'out>(&'out mut self) -> Out<'out, [T]>

source§

impl<T> AsOut<[T]> for [T; 4]where T: Copy,

source§

fn as_out<'out>(&'out mut self) -> Out<'out, [T]>

source§

impl<T> AsOut<[T]> for [T; 48]where T: Copy,

source§

fn as_out<'out>(&'out mut self) -> Out<'out, [T]>

source§

impl<T> AsOut<[T]> for [T; 7]where T: Copy,

source§

fn as_out<'out>(&'out mut self) -> Out<'out, [T]>

source§

impl<T> AsOut<[T]> for [MaybeUninit<T>; 39]

source§

fn as_out<'out>(&'out mut self) -> Out<'out, [T]>

source§

impl<T> AsOut<[T]> for [T; 49]where T: Copy,

source§

fn as_out<'out>(&'out mut self) -> Out<'out, [T]>

source§

impl<T> AsOut<[T]> for [MaybeUninit<T>; 62]

source§

fn as_out<'out>(&'out mut self) -> Out<'out, [T]>

source§

impl<T> AsOut<[T]> for [T; 6]where T: Copy,

source§

fn as_out<'out>(&'out mut self) -> Out<'out, [T]>

source§

impl<T> AsOut<[T]> for [MaybeUninit<T>; 38]

source§

fn as_out<'out>(&'out mut self) -> Out<'out, [T]>

source§

impl<T> AsOut<[T]> for [T; 54]where T: Copy,

source§

fn as_out<'out>(&'out mut self) -> Out<'out, [T]>

source§

impl<T> AsOut<[T]> for [MaybeUninit<T>; 11]

source§

fn as_out<'out>(&'out mut self) -> Out<'out, [T]>

source§

impl<T> AsOut<[T]> for [MaybeUninit<T>; 27]

source§

fn as_out<'out>(&'out mut self) -> Out<'out, [T]>

Implementors§

source§

impl<T> AsOut<T> for MaybeUninit<T>

source§

impl<T> AsOut<T> for Twhere T: Copy,