1use core::any::{Any, TypeId};
6
7fn type_of<U, V>() -> bool
9where
10 U: core::any::Any + ?Sized,
11 V: core::any::Any + ?Sized,
12{
13 core::any::TypeId::of::<U>() == core::any::TypeId::of::<V>()
14}
15pub trait TypeOf {
18 private!();
19
20 fn of<T: 'static>() -> bool;
21}
22pub trait IsType {
26 private!();
27
28 fn is<T>(&self) -> bool
29 where
30 T: 'static,
31 Self: 'static,
32 {
33 type_of::<Self, T>()
34 }
35}
36
37pub trait DType: 'static + IsType + TypeOf {
40 private!();
41
42 fn type_id(&self) -> TypeId {
43 Any::type_id(self)
44 }
45
46 fn type_name(&self) -> &'static str {
47 core::any::type_name::<Self>()
48 }
49}
50
51impl<T> DType for T
55where
56 T: 'static,
57{
58 seal!();
59
60 fn type_id(&self) -> TypeId {
61 Any::type_id(self)
62 }
63
64 fn type_name(&self) -> &'static str {
65 core::any::type_name::<Self>()
66 }
67}
68
69impl<T> TypeOf for T
70where
71 T: 'static,
72{
73 seal!();
74
75 fn of<U: 'static>() -> bool {
76 type_of::<T, U>()
77 }
78}
79
80impl<T> IsType for T
81where
82 T: 'static,
83{
84 seal!();
85}