2015-01-15 01:08:07 +01:00
|
|
|
use core::any::TypeId;
|
2015-01-06 22:59:07 +01:00
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_typeid_sized_types() {
|
2019-12-07 05:18:12 +01:00
|
|
|
struct X;
|
|
|
|
struct Y(u32);
|
2015-01-06 22:59:07 +01:00
|
|
|
|
|
|
|
assert_eq!(TypeId::of::<X>(), TypeId::of::<X>());
|
|
|
|
assert_eq!(TypeId::of::<Y>(), TypeId::of::<Y>());
|
|
|
|
assert!(TypeId::of::<X>() != TypeId::of::<Y>());
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_typeid_unsized_types() {
|
|
|
|
trait Z {}
|
2019-12-07 05:18:12 +01:00
|
|
|
struct X(str);
|
|
|
|
struct Y(dyn Z + 'static);
|
2015-01-06 22:59:07 +01:00
|
|
|
|
|
|
|
assert_eq!(TypeId::of::<X>(), TypeId::of::<X>());
|
|
|
|
assert_eq!(TypeId::of::<Y>(), TypeId::of::<Y>());
|
|
|
|
assert!(TypeId::of::<X>() != TypeId::of::<Y>());
|
|
|
|
}
|