use core::marker::PhantomData;
use erased::Erased;
use crate::lt_list::LtList;
use crate::tag::{Reify, TagTypeId};
mod erased;
pub struct MutErasedWide<'u, L: LtList> {
_lt: PhantomData<&'u mut dyn core::any::Any>,
borrow: Erased<{ core::mem::size_of::<&mut dyn core::any::Any>() }>,
tag_type_id: TagTypeId<L>,
}
impl<'u, L: LtList> MutErasedWide<'u, L> {
pub fn new<T: ?Sized + Reify<L>>(borrow: &'u mut T::Reified) -> Self {
Self {
_lt: PhantomData,
borrow: Erased::new::<&'u mut T::Reified>(borrow),
tag_type_id: TagTypeId::<L>::of::<T>(),
}
}
pub fn downcast<T: ?Sized + Reify<L>>(self) -> Result<&'u mut T::Reified, Self> {
if self.tag_type_id == TagTypeId::<L>::of::<T>() {
Ok(unsafe { self.borrow.into_inner::<&'u mut T::Reified>() })
} else {
Err(self)
}
}
}