1use crate::any::TypeId;
5use crate::intrinsics::type_of;
6
7#[derive(Debug)]
9#[non_exhaustive]
10#[lang = "type_info"]
11#[unstable(feature = "type_info", issue = "146922")]
12pub struct Type {
13 pub kind: TypeKind,
15 pub size: Option<usize>,
17}
18
19impl TypeId {
20 #[unstable(feature = "type_info", issue = "146922")]
23 #[rustc_const_unstable(feature = "type_info", issue = "146922")]
24 pub const fn info(self) -> Type {
25 type_of(self)
26 }
27}
28
29impl Type {
30 #[unstable(feature = "type_info", issue = "146922")]
32 #[rustc_const_unstable(feature = "type_info", issue = "146922")]
33 pub const fn of<T: 'static>() -> Self {
35 const { TypeId::of::<T>().info() }
36 }
37}
38
39#[derive(Debug)]
41#[non_exhaustive]
42#[unstable(feature = "type_info", issue = "146922")]
43pub enum TypeKind {
44 Tuple(Tuple),
46 Leaf,
49 Other,
51}
52
53#[derive(Debug)]
55#[non_exhaustive]
56#[unstable(feature = "type_info", issue = "146922")]
57pub struct Tuple {
58 pub fields: &'static [Field],
60}
61
62#[derive(Debug)]
64#[non_exhaustive]
65#[unstable(feature = "type_info", issue = "146922")]
66pub struct Field {
67 pub ty: TypeId,
69 pub offset: usize,
71}