use alloc::boxed::Box;
use crate::frame::VTable;
#[repr(C)]
pub(in crate::frame) struct ErasableFrame<T = ()> {
vtable: &'static VTable,
pub(in crate::frame) _unerased: T,
}
impl<T> ErasableFrame<T> {
pub(in crate::frame) unsafe fn new(object: T, vtable: &'static VTable) -> Box<ErasableFrame> {
let unerased_frame = Self {
vtable,
_unerased: object,
};
let unerased_box = Box::new(unerased_frame);
Box::from_raw(Box::into_raw(unerased_box).cast())
}
}
impl ErasableFrame {
pub(in crate::frame) const fn vtable(&self) -> &'static VTable {
self.vtable
}
}