diff --git a/src/data_source.rs b/src/data_source.rs index 9b9d35a..e5bbdb6 100644 --- a/src/data_source.rs +++ b/src/data_source.rs @@ -5,7 +5,7 @@ use log::{error, info}; use serde_derive::{Deserialize, Serialize}; use serde_json::Value; use std::fs; -use std::path::PathBuf; +use std::path::Path; #[derive(Serialize, Deserialize)] struct ItemSet { @@ -57,7 +57,7 @@ pub trait DataSource { &self, champ: &ChampInfo, positions: &[String], - path: &PathBuf, + path: &Path, client: &ureq::Agent, ) { info!( diff --git a/src/kb_data_source.rs b/src/kb_data_source.rs index a04d342..cddb196 100644 --- a/src/kb_data_source.rs +++ b/src/kb_data_source.rs @@ -115,10 +115,7 @@ fn get_auth_token() -> Option { None => return None, }; bundle = (&bundle[(q_position + 1)..]).to_string(); - match bundle.find('"') { - Some(position) => Some((&bundle[..position]).to_string()), - None => None, - } + bundle.find('"').map(|position| (&bundle[..position]).to_string()) } impl KBDataSource { diff --git a/src/main.rs b/src/main.rs index 6d63348..ebd7cab 100644 --- a/src/main.rs +++ b/src/main.rs @@ -11,7 +11,7 @@ use std::io; use std::io::Error; #[cfg(target_os = "windows")] use std::io::ErrorKind; -use std::path::PathBuf; +use std::path::{Path, PathBuf}; use std::time::Instant; use std::{fs, thread, time}; use time::Duration; @@ -128,7 +128,7 @@ fn execute_data_source( data_source: &(dyn DataSource + Sync + Send), client: &ureq::Agent, champion: &Champion, - lol_champs_dir: &PathBuf, + lol_champs_dir: &Path, ) { let champs = data_source.get_champs_with_positions(&client, &champion); @@ -168,7 +168,7 @@ fn get_and_write_item_set( data_source: &(dyn DataSource + Sync + Send), client: &ureq::Agent, champion: &Champion, - lol_champs_dir: &PathBuf, + lol_champs_dir: &Path, id: u32, positions: &[String], ) { diff --git a/src/ms_data_source.rs b/src/ms_data_source.rs index 63e1ab3..6ca29cd 100644 --- a/src/ms_data_source.rs +++ b/src/ms_data_source.rs @@ -36,9 +36,9 @@ impl DataSource for MSDataSource { let role = &page[p + page[p..].find('/').unwrap() + 1..p + page[p..].find('"').unwrap()]; - let k = p + &page[p..].find("data-search-terms-like=\"").unwrap() + 24; - let pipe = k + &page[k..].find("|").unwrap() + 1; - let key = &page[pipe..pipe + &page[pipe..].find('"').unwrap()]; + let k = p + page[p..].find("data-search-terms-like=\"").unwrap() + 24; + let pipe = k + page[k..].find('|').unwrap() + 1; + let key = &page[pipe..pipe + page[pipe..].find('"').unwrap()]; let id = champion.data.get(key).unwrap().key.parse::().unwrap(); @@ -82,7 +82,7 @@ impl DataSource for MSDataSource { let mut pos: Option = page.find("/item/"); while let Some(mut p) = pos { p += 6; - let i = &page[p..p + &page[p..].find('.').unwrap()]; + let i = &page[p..p + page[p..].find('.').unwrap()]; items.push(i);