use_prelude!();
use crate::extension_traits::Transpose;
use ::core::mem::ManuallyDrop;
pub trait AsOut<Pointee: ?Sized> {
#[allow(missing_docs)]
fn as_out<'out>(self: &'out mut Self) -> Out<'out, Pointee>;
}
impl<T> AsOut<T> for MaybeUninit<T> {
#[inline]
fn as_out<'out>(self: &'out mut MaybeUninit<T>) -> Out<'out, T> {
self.into()
}
}
impl<T> AsOut<T> for T
where
T: Copy,
{
#[inline]
fn as_out<'out>(self: &'out mut T) -> Out<'out, T> {
self.into()
}
}
impl<T> AsOut<[T]> for [MaybeUninit<T>] {
#[inline]
fn as_out<'out>(self: &'out mut [MaybeUninit<T>]) -> Out<'out, [T]> {
self.into()
}
}
impl<T> AsOut<[T]> for [T]
where
T: Copy,
{
#[inline]
fn as_out<'out>(self: &'out mut [T]) -> Out<'out, [T]> {
self.into()
}
}
impl<T: ?Sized> AsOut<T> for ManuallyDrop<T> {
#[inline]
fn as_out<'out>(self: &'out mut ManuallyDrop<T>) -> Out<'out, T> {
self.into()
}
}
impl<T> AsOut<[T]> for [ManuallyDrop<T>] {
#[inline]
fn as_out<'out>(self: &'out mut [ManuallyDrop<T>]) -> Out<'out, [T]> {
self.into()
}
}
impl<T, const N: usize> AsOut<[T]> for MaybeUninit<[T; N]> {
#[inline]
fn as_out<'out>(self: &'out mut Self) -> Out<'out, [T]> {
From::from(&mut self.transpose()[..])
}
}
impl<T, const N: usize> AsOut<[T]> for [MaybeUninit<T>; N] {
#[inline]
fn as_out<'out>(self: &'out mut Self) -> Out<'out, [T]> {
From::from(&mut self[..])
}
}
impl<T, const N: usize> AsOut<[T]> for [T; N]
where
T: Copy,
{
#[inline]
fn as_out<'out>(self: &'out mut Self) -> Out<'out, [T]> {
From::from(&mut self[..])
}
}