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