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}
15
16pub trait TypeOf {
17 fn of<T: 'static>() -> bool;
18}
19
20pub trait IsType {
21 fn is<T>(&self) -> bool
22 where
23 T: 'static,
24 Self: 'static,
25 {
26 type_of::<Self, T>()
27 }
28}
29
30pub trait DType: Any {
33 private!();
34
35 fn type_id(&self) -> TypeId {
36 Any::type_id(self)
37 }
38
39 fn type_name(&self) -> &'static str {
40 core::any::type_name::<Self>()
41 }
42}
43
44impl<T> TypeOf for T
48where
49 T: Any,
50{
51 fn of<U: 'static>() -> bool {
52 type_of::<T, U>()
53 }
54}
55
56impl<T: 'static> IsType for T {}
57
58impl dyn DType {}