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