1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
use std::fmt;
use crate::List;
use crate::Int;
use crate::Float;
use crate::_String;
use crate::Char;
use crate::Bool;
pub trait _Object {
fn __repr__(&self) -> String;
fn __str__(&self) -> String;
}
pub enum Object {
Char(Char),
Int32(Int<i32>),
Int64(Int<i64>),
Float32(Float<f32>),
Float64(Float<f64>),
String(_String),
List(List),
Bool(Bool),
}
impl fmt::Display for Object {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match &*self {
Object::Char(_char) => write!(f, "{}", _char),
Object::Int32(_int) => write!(f, "{}", _int),
Object::Int64(_int) => write!(f, "{}", _int),
Object::Float32(_float) => write!(f, "{}", _float),
Object::Float64(_float) => write!(f, "{}", _float),
Object::String(_string) => write!(f, "{}", _string),
Object::List(_list) => write!(f, "{}", _list),
Object::Bool(_bool) => write!(f, "{}", _bool),
}
}
}
impl fmt::Debug for Object {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match &*self {
Object::Char(_char) => write!(f, "{:?}", _char),
Object::Int32(_int) => write!(f, "{:?}", _int),
Object::Int64(_int) => write!(f, "{:?}", _int),
Object::Float32(_float) => write!(f, "{:?}", _float),
Object::Float64(_float) => write!(f, "{:?}", _float),
Object::String(_string) => write!(f, "{:?}", _string),
Object::List(_list) => write!(f, "{:?}", _list),
Object::Bool(_bool) => write!(f, "{:?}", _bool),
}
}
}