diff --git a/src/build_tools/cmake.rs b/src/build_tools/cmake.rs index ba9adbb..265fbd6 100644 --- a/src/build_tools/cmake.rs +++ b/src/build_tools/cmake.rs @@ -17,8 +17,8 @@ impl Cmake { "-G".into(), "Ninja".into(), ]; - if self.vars.is_some() { - for (k, v) in self.vars.as_ref().unwrap() { + if let Some(vars) = self.vars.as_ref() { + for (k, v) in vars { if k.contains(' ') { panic!("Cmake vars cannot contain spaces!"); } diff --git a/src/profile.rs b/src/profile.rs index 2b78439..20f2019 100644 --- a/src/profile.rs +++ b/src/profile.rs @@ -854,9 +854,9 @@ impl Profile { } pub fn basalt_git(&self) -> Option { - if !self.features.basalt.enabled || self.features.basalt.path.is_none() { - None - } else { + if self.features.basalt.enabled + && let Some(basalt_path) = self.features.basalt.path.as_ref() + { Some(Git { repo: self .features @@ -865,7 +865,7 @@ impl Profile { .as_deref() .unwrap_or(DEFAULT_BASALT_REPO) .into(), - dir: self.features.basalt.path.as_ref().unwrap().clone(), + dir: basalt_path.clone(), branch: self .features .basalt @@ -874,13 +874,15 @@ impl Profile { .unwrap_or(DEFAULT_BASALT_BRANCH) .into(), }) + } else { + None } } pub fn openhmd_git(&self) -> Option { - if !self.features.openhmd.enabled || self.features.openhmd.path.is_none() { - None - } else { + if self.features.openhmd.enabled + && let Some(openhmd_path) = self.features.openhmd.path.as_ref() + { Some(Git { repo: self .features @@ -889,7 +891,7 @@ impl Profile { .as_deref() .unwrap_or(DEFAULT_OPENHMD_REPO) .into(), - dir: self.features.openhmd.path.as_ref().unwrap().clone(), + dir: openhmd_path.clone(), branch: self .features .openhmd @@ -898,13 +900,15 @@ impl Profile { .unwrap_or(DEFAULT_OPENHMD_BRANCH) .into(), }) + } else { + None } } pub fn libsurvive_git(&self) -> Option { - if !self.features.libsurvive.enabled || self.features.libsurvive.path.is_none() { - None - } else { + if self.features.libsurvive.enabled + && let Some(libsurvive_path) = self.features.libsurvive.path.as_ref() + { Some(Git { repo: self .features @@ -913,7 +917,7 @@ impl Profile { .as_deref() .unwrap_or(DEFAULT_LIBSURVIVE_REPO) .into(), - dir: self.features.libsurvive.path.as_ref().unwrap().clone(), + dir: libsurvive_path.clone(), branch: self .features .libsurvive @@ -922,6 +926,8 @@ impl Profile { .unwrap_or(DEFAULT_LIBSURVIVE_BRANCH) .into(), }) + } else { + None } } diff --git a/src/ui/libsurvive_setup_window.rs b/src/ui/libsurvive_setup_window.rs index 9b4c004..1487673 100644 --- a/src/ui/libsurvive_setup_window.rs +++ b/src/ui/libsurvive_setup_window.rs @@ -441,9 +441,8 @@ impl SimpleComponent for LibsurviveSetupWindow { if !self.first_run_done && self.calibration_seconds_elapsed >= CALIBRATION_RUN_TIME_SECONDS { - if self.calibration_runner.is_some() { + if let Some(runner) = self.calibration_runner.as_mut() { self.first_run_done = true; - let runner = self.calibration_runner.as_mut().unwrap(); runner.terminate(); let mut n_runner = self.create_calibration_runner( &self