clean code
This commit is contained in:
parent
bbe90195d5
commit
6947fbe05a
1 changed files with 5 additions and 9 deletions
14
src/main.rs
14
src/main.rs
|
@ -179,8 +179,11 @@ fn get_champ_data(id: &str, position: &str, client: &reqwest::Client) -> Option<
|
|||
))
|
||||
.send()
|
||||
.unwrap();
|
||||
if req.status() == reqwest::StatusCode::Ok {
|
||||
serde_json::from_str(&find_champ_data(&req.text().unwrap())).unwrap()
|
||||
if req.status().is_success() {
|
||||
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 {
|
||||
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> {
|
||||
let hklm = RegKey::predef(winreg::enums::HKEY_LOCAL_MACHINE);
|
||||
let node = hklm.open_subkey(r"SOFTWARE\WOW6432Node\Riot Games\RADS")?;
|
||||
|
|
Loading…
Add table
Reference in a new issue