1use crate::source_tracking::fragment::Fragment;
4
5#[derive(Debug, Clone)]
7#[allow(missing_docs)]
8pub enum Type {
9 Atomic(AtomicTy),
10 Reference(ReferenceTy),
11}
12
13impl Type {
14 pub fn matching_source(&self) -> &Fragment {
16 match self {
17 Type::Atomic(atomic_ty) => &atomic_ty.matching_source,
18 Type::Reference(reference_ty) => &reference_ty.matching_source,
19 }
20 }
21
22 pub fn downcast_primitive(&self) -> Option<&AtomicTy> {
24 match self {
25 Type::Atomic(atomic) => Some(atomic),
26 _ => None,
27 }
28 }
29
30 pub fn downcast_reference(&self) -> Option<&ReferenceTy> {
32 match self {
33 Type::Reference(reference) => Some(reference),
34 _ => None,
35 }
36 }
37}
38
39#[derive(Clone, Copy, Debug, PartialEq, Eq)]
41#[allow(missing_docs)]
42pub enum AtomicTyVariant {
43 Bool,
44 U8,
45 I8,
46 U16,
47 I16,
48 U32,
49 I32,
50 U64,
51 I64,
52 F32,
53 F64,
54 Char,
55}
56
57#[derive(Clone, Debug)]
59#[allow(missing_docs)]
60pub struct AtomicTy {
61 pub variant: AtomicTyVariant,
62 pub matching_source: Fragment,
63}
64
65#[derive(Debug, Clone)]
67pub struct ReferenceTy {
68 pub target_ty: Box<Type>,
70 pub matching_source: Fragment,
72}