clean code

This commit is contained in:
nyyu 2018-06-09 11:10:49 +02:00
parent bbe90195d5
commit 6947fbe05a

View file

@ -179,8 +179,11 @@ fn get_champ_data(id: &str, position: &str, client: &reqwest::Client) -> Option<
)) ))
.send() .send()
.unwrap(); .unwrap();
if req.status() == reqwest::StatusCode::Ok { if req.status().is_success() {
serde_json::from_str(&find_champ_data(&req.text().unwrap())).unwrap() lazy_static! {
static ref RE: Regex = Regex::new(r"(?m)^\s+matchupData\.championData = (.*)$").unwrap();
}
serde_json::from_str(&RE.captures(&req.text().unwrap())?[1]).unwrap()
} else { } else {
None None
} }
@ -256,13 +259,6 @@ fn write_item_set(id: &str, pos: &str, ver: &str, path: &PathBuf, client: &reqwe
} }
} }
fn find_champ_data(text: &str) -> String {
lazy_static! {
static ref RE: Regex = Regex::new(r"(?m)^\s+matchupData\.championData = (.*)$").unwrap();
}
RE.captures(text).unwrap()[1].to_string()
}
fn lol_champ_dir() -> Result<PathBuf, io::Error> { fn lol_champ_dir() -> Result<PathBuf, io::Error> {
let hklm = RegKey::predef(winreg::enums::HKEY_LOCAL_MACHINE); let hklm = RegKey::predef(winreg::enums::HKEY_LOCAL_MACHINE);
let node = hklm.open_subkey(r"SOFTWARE\WOW6432Node\Riot Games\RADS")?; let node = hklm.open_subkey(r"SOFTWARE\WOW6432Node\Riot Games\RADS")?;