From d02a3c6a1dd38c707522632c90390c65b9f65e13 Mon Sep 17 00:00:00 2001 From: nyyu Date: Sun, 14 Mar 2021 13:10:04 +0100 Subject: [PATCH] lint --- src/main.rs | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/src/main.rs b/src/main.rs index 5049b85..6c7402e 100644 --- a/src/main.rs +++ b/src/main.rs @@ -158,28 +158,26 @@ fn lol_champ_dir() -> Result { let node = hklm.open_subkey(r"SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall"); let mut sub_node: io::Result = Err(Error::from(ErrorKind::NotFound)); - if node.is_ok() { - let n = node.unwrap(); + if let Ok(n) = node { let key = n .enum_keys() .map(|x| x.unwrap()) .find(|x| x.starts_with("League of Legends")); - if key.is_some() { - sub_node = n.open_subkey(key.unwrap()); + if let Some(k) = key { + sub_node = n.open_subkey(k); } - } + } if sub_node.is_err() { let hkcu = RegKey::predef(winreg::enums::HKEY_CURRENT_USER); let node = hkcu.open_subkey(r"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\"); - if node.is_ok() { - let n = node.unwrap(); + if let Ok(n) = node { let key = n .enum_keys() .map(|x| x.unwrap()) .find(|x| x == "Riot Game league_of_legends.live"); - if key.is_some() { - sub_node = n.open_subkey(key.unwrap()); + if let Some(k) = key { + sub_node = n.open_subkey(k); } } } @@ -189,7 +187,6 @@ fn lol_champ_dir() -> Result { return Ok(PathBuf::from(val).join("Config").join("Champions")); } - Err(Error::from(ErrorKind::NotFound)) }