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
use std::fmt::Display;
mod features;
mod from_arma;
mod into_arma;
pub use from_arma::FromArma;
pub use into_arma::IntoArma;
#[derive(Debug, Clone, PartialEq, PartialOrd)]
pub enum Value {
Null,
Number(f64),
Array(Vec<Value>),
Boolean(bool),
String(String),
}
impl Display for Value {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Self::Null => write!(f, "null"),
Self::Number(n) => write!(f, "{}", n),
Self::Array(a) => write!(
f,
"[{}]",
a.iter()
.map(ToString::to_string)
.collect::<Vec<String>>()
.join(",")
),
Self::Boolean(b) => write!(f, "{}", b),
Self::String(s) => write!(f, "\"{}\"", s.replace('\"', "\"\"")),
}
}
}