1#[derive(Clone, Copy)]
3pub enum Type<'a> {
4 Boolean,
6 Byte,
8 Char,
10 Short,
12 Int,
14 Long,
16 Float,
18 Double,
20 Void,
22 Object(&'a str),
24 Array(&'a Type<'a>),
26}
27
28impl<'a> From<Type<'a>> for String {
29 fn from(r#type: Type) -> Self {
30 let result = match r#type {
31 Type::Boolean => "Z".into(),
32 Type::Byte => "B".into(),
33 Type::Char => "C".into(),
34 Type::Short => "S".into(),
35 Type::Int => "I".into(),
36 Type::Long => "J".into(),
37 Type::Float => "F".into(),
38 Type::Double => "D".into(),
39 Type::Void => "V".into(),
40 Type::Object(s) => format!("L{};", s),
41 Type::Array(t) => format!("[{}", <Type as Into<String>>::into(*t)),
42 };
43
44 result
45 }
46}