Add a trait to get the vtable for a type

This commit is contained in:
Olivier Goffart 2020-05-16 08:39:10 +02:00
parent 4ca45ca4da
commit b745c616f7
5 changed files with 72 additions and 13 deletions

View file

@ -19,6 +19,16 @@ pub trait VTableMetaDrop: VTableMeta {
unsafe fn drop(ptr: *mut Self::Target);
}
/// Allow to associate a VTable to a type.
pub unsafe trait HasStaticVTable<VT>
where
VT: ?Sized + VTableMeta,
VT::VTable: 'static,
{
/// Savety: must be a valid VTable for Self
const VTABLE: VT::VTable;
}
#[derive(Copy, Clone)]
/// The inner structure of VRef, VRefMut, and VBox.
///