use std::pin::Pin;
use crate::misc::either::Either;
impl<L, R> Either<L, R> {
pub fn as_pin_ref(self: Pin<&Self>) -> Either<Pin<&L>, Pin<&R>> {
unsafe {
match self.get_ref() {
Either::Left(x) => Either::Left(Pin::new_unchecked(x)),
Either::Right(x) => Either::Right(Pin::new_unchecked(x)),
}
}
}
pub fn as_pin_mut(self: Pin<&mut Self>) -> Either<Pin<&mut L>, Pin<&mut R>> {
unsafe {
match self.get_unchecked_mut() {
Either::Left(x) => Either::Left(Pin::new_unchecked(x)),
Either::Right(x) => Either::Right(Pin::new_unchecked(x)),
}
}
}
}
impl<L, R> Unpin for Either<L, R>
where
L: Unpin,
R: Unpin,
{
}
#[allow(dead_code)]
trait MustNotImplDrop {}
#[allow(drop_bounds)]
impl<T: Drop> MustNotImplDrop for T {}
impl<L, R> MustNotImplDrop for Either<L, R> {}