From bdf6f979235ef47fea35650df419c2f391fc418e Mon Sep 17 00:00:00 2001 From: nyyu Date: Tue, 16 Mar 2021 20:25:14 +0100 Subject: [PATCH] oops format --- src/pb_data_source.rs | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/src/pb_data_source.rs b/src/pb_data_source.rs index 840ace9..e511b99 100644 --- a/src/pb_data_source.rs +++ b/src/pb_data_source.rs @@ -15,7 +15,7 @@ struct ChampionResponse { #[derive(Deserialize, Debug)] struct Champion { key: String, - name: String + name: String, } impl DataSource for PBDataSource { @@ -29,19 +29,18 @@ impl DataSource for PBDataSource { 300 } - fn get_champs_with_positions( - &self, - client: &ureq::Agent, - ) -> IndexMap> { + fn get_champs_with_positions(&self, client: &ureq::Agent) -> IndexMap> { let mut champs = IndexMap::new(); let page = client - .get("https://www.probuilds.net/ajax/championListNew") - .set("Accept", "application/json") - .call().unwrap().into_string().unwrap(); + .get("https://www.probuilds.net/ajax/championListNew") + .set("Accept", "application/json") + .call() + .unwrap() + .into_string() + .unwrap(); - let data: ChampionResponse = - serde_json::from_str(&page).unwrap(); + let data: ChampionResponse = serde_json::from_str(&page).unwrap(); for champ in data.champions { champs.insert(champ.key.parse::().unwrap(), vec!["ANY".to_owned()]); @@ -56,7 +55,6 @@ impl DataSource for PBDataSource { positions: &[String], client: &ureq::Agent, ) -> Vec<(String, Vec, Stat)> { - let mut builds = vec![]; let page = client @@ -68,10 +66,10 @@ impl DataSource for PBDataSource { let mut build = &page[page.find("'items'").unwrap()..]; while build.contains("items") { let pos = build.find("data-id=").unwrap(); - build = &build[pos+10..]; + build = &build[pos + 10..]; let end = build.find('\\').unwrap(); items.push(&build[..end]); - build = &build[pos+22..]; + build = &build[pos + 22..]; } builds.push((positions[0].to_owned(), vec![json!({ @@ -79,7 +77,6 @@ impl DataSource for PBDataSource { "type": "Set" })], Stat{win_rate:0.0,games:1,kda:0.0,patch:"".to_string()})); - builds } }