Add Archetype TypeInfo::type_name accessor (#985)

This commit is contained in:
Tomasz Sterna 2020-12-02 23:33:17 +01:00 committed by GitHub
parent 915024bf35
commit c346d282b6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -484,7 +484,6 @@ pub struct TypeInfo {
id: TypeId, id: TypeId,
layout: Layout, layout: Layout,
drop: unsafe fn(*mut u8), drop: unsafe fn(*mut u8),
#[cfg(debug_assertions)]
type_name: &'static str, type_name: &'static str,
} }
@ -499,7 +498,6 @@ impl TypeInfo {
id: TypeId::of::<T>(), id: TypeId::of::<T>(),
layout: Layout::new::<T>(), layout: Layout::new::<T>(),
drop: drop_ptr::<T>, drop: drop_ptr::<T>,
#[cfg(debug_assertions)]
type_name: core::any::type_name::<T>(), type_name: core::any::type_name::<T>(),
} }
} }
@ -519,6 +517,12 @@ impl TypeInfo {
pub(crate) unsafe fn drop(&self, data: *mut u8) { pub(crate) unsafe fn drop(&self, data: *mut u8) {
(self.drop)(data) (self.drop)(data)
} }
#[allow(missing_docs)]
#[inline]
pub fn type_name(&self) -> &'static str {
self.type_name
}
} }
impl PartialOrd for TypeInfo { impl PartialOrd for TypeInfo {