From fa34717836d154cd11046301f55cfb7e4afeae7c Mon Sep 17 00:00:00 2001 From: nyyu Date: Sun, 21 Apr 2019 22:34:08 +0200 Subject: [PATCH] format --- src/data_source.rs | 15 ++++++++------- src/main.rs | 5 ++++- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/data_source.rs b/src/data_source.rs index 78a14d5..be9cb84 100644 --- a/src/data_source.rs +++ b/src/data_source.rs @@ -47,9 +47,9 @@ pub trait DataSource { fn make_item_set(&self, data: &Value, label: &str) -> Value { json!({ - "items": data["items"].as_array().unwrap().iter().map(|x| json!({"id": x["id"].as_str(), "count": 1})).collect::>(), - "type": format!("{} ({:.2}% - {} games)", label, data["winPercent"].as_f64().unwrap() * 100., data["games"].as_u64().unwrap()) - }) + "items": data["items"].as_array().unwrap().iter().map(|x| json!({"id": x["id"].as_str(), "count": 1})).collect::>(), + "type": format!("{} ({:.2}% - {} games)", label, data["winPercent"].as_f64().unwrap() * 100., data["games"].as_u64().unwrap()) + }) } fn make_item_set_from_list( @@ -75,9 +75,9 @@ pub trait DataSource { .join("."); } json!({ - "items": list.iter().map(|x| json!({"id": x.to_string(), "count": 1})).collect::>(), - "type": format!("{} {}", label, key_order) - }) + "items": list.iter().map(|x| json!({"id": x.to_string(), "count": 1})).collect::>(), + "type": format!("{} {}", label, key_order) + }) } fn write_item_set( &self, @@ -133,7 +133,8 @@ pub trait DataSource { fs::write( path.join(format!("CGG_{}_{}.json", id, pos)), serde_json::to_string_pretty(&item_set).unwrap(), - ).unwrap(); + ) + .unwrap(); } None => { error!("Can't get data for {} at {}", id, pos); diff --git a/src/main.rs b/src/main.rs index ab96a66..d29ae3f 100644 --- a/src/main.rs +++ b/src/main.rs @@ -60,7 +60,10 @@ fn main() { info!("LoL Champs Folder: {}", lol_champs_dir.to_str().unwrap()); let mut headers = header::HeaderMap::new(); - headers.insert(header::USER_AGENT, header::HeaderValue::from_static(USER_AGENT)); + headers.insert( + header::USER_AGENT, + header::HeaderValue::from_static(USER_AGENT), + ); let client = reqwest::Client::builder() .default_headers(headers)