mirascript_vm/value/
type_enum.rs1use std::fmt;
2
3#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
5pub enum MiraType {
6 Nil,
8 Boolean,
10 Number,
12 String,
14 Array,
16 Record,
18 Function,
20 Module,
22 Extern,
24}
25
26impl MiraType {
27 #[inline]
29 pub const fn name(self) -> &'static str {
30 match self {
31 Self::Nil => "nil",
32 Self::Boolean => "boolean",
33 Self::Number => "number",
34 Self::String => "string",
35 Self::Array => "array",
36 Self::Record => "record",
37 Self::Function => "function",
38 Self::Module => "module",
39 Self::Extern => "extern",
40 }
41 }
42}
43
44impl fmt::Display for MiraType {
45 fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
46 formatter.write_str(self.name())
47 }
48}