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
|
use serde_json::{Value, Map};
use handlebars_iron::handlebars::to_json;
#[derive(Serialize, Debug)]
pub struct Quote {
id: u64,
author: String,
date: String,
score: String,
votes: u32,
content: String
}
pub fn make_data() -> Map<String, Value> {
let mut data = Map::new();
data.insert("quotes".to_string(), to_json(&vec!(
&Quote {
id: 1,
author: "panda_man".to_owned(),
date: "2017-07-01".to_owned(),
score: format!("{:.2}", 450.0 / 96.0),
votes: 99,
content: "<orbekk> hvor er jantho?".to_owned(),
}
)));
data
}
|