From c140d191c91e56ce07554352eba6566074bced35 Mon Sep 17 00:00:00 2001 From: Gabriele Musco Date: Mon, 13 May 2024 14:35:53 +0200 Subject: [PATCH] fix(builders): prefer unwrap_or to pattern matching --- src/builders/build_basalt.rs | 22 ++++++++++++++-------- src/builders/build_libsurvive.rs | 22 ++++++++++++++-------- src/builders/build_monado.rs | 18 ++++++++++-------- src/builders/build_opencomposite.rs | 18 ++++++++++-------- src/builders/build_openhmd.rs | 22 ++++++++++++++-------- src/builders/build_wivrn.rs | 18 ++++++++++-------- 6 files changed, 72 insertions(+), 48 deletions(-) diff --git a/src/builders/build_basalt.rs b/src/builders/build_basalt.rs index 1edd4d1..8e3c346 100644 --- a/src/builders/build_basalt.rs +++ b/src/builders/build_basalt.rs @@ -13,15 +13,21 @@ pub fn get_build_basalt_jobs(profile: &Profile, clean_build: bool) -> VecDeque::new(); let git = Git { - repo: match profile.features.basalt.repo.as_ref() { - Some(r) => r.clone(), - None => "https://gitlab.freedesktop.org/mateosss/basalt.git".into(), - }, + repo: profile + .features + .basalt + .repo + .as_ref() + .unwrap_or(&"https://gitlab.freedesktop.org/mateosss/basalt.git".into()) + .clone(), dir: profile.features.basalt.path.as_ref().unwrap().clone(), - branch: match profile.features.basalt.branch.as_ref() { - Some(r) => r.clone(), - None => "main".into(), - }, + branch: profile + .features + .basalt + .branch + .as_ref() + .unwrap_or(&"main".into()) + .clone(), }; jobs.extend(git.get_pre_build_jobs(profile.pull_on_build)); diff --git a/src/builders/build_libsurvive.rs b/src/builders/build_libsurvive.rs index f78cd20..8ddd206 100644 --- a/src/builders/build_libsurvive.rs +++ b/src/builders/build_libsurvive.rs @@ -13,15 +13,21 @@ pub fn get_build_libsurvive_jobs(profile: &Profile, clean_build: bool) -> VecDeq let mut jobs = VecDeque::::new(); let git = Git { - repo: match profile.features.libsurvive.repo.as_ref() { - Some(r) => r.clone(), - None => "https://github.com/cntools/libsurvive".into(), - }, + repo: profile + .features + .libsurvive + .repo + .as_ref() + .unwrap_or(&"https://github.com/cntools/libsurvive".into()) + .clone(), dir: profile.features.libsurvive.path.as_ref().unwrap().clone(), - branch: match profile.features.libsurvive.branch.as_ref() { - Some(r) => r.clone(), - None => "master".into(), - }, + branch: profile + .features + .libsurvive + .branch + .as_ref() + .unwrap_or(&"master".into()) + .clone(), }; jobs.extend(git.get_pre_build_jobs(profile.pull_on_build)); diff --git a/src/builders/build_monado.rs b/src/builders/build_monado.rs index 1bb875b..fb049c5 100644 --- a/src/builders/build_monado.rs +++ b/src/builders/build_monado.rs @@ -13,15 +13,17 @@ pub fn get_build_monado_jobs(profile: &Profile, clean_build: bool) -> VecDeque::new(); let git = Git { - repo: match profile.xrservice_repo.as_ref() { - Some(r) => r.clone(), - None => "https://gitlab.freedesktop.org/monado/monado".into(), - }, + repo: profile + .xrservice_repo + .as_ref() + .unwrap_or(&"https://gitlab.freedesktop.org/monado/monado".into()) + .clone(), dir: profile.xrservice_path.clone(), - branch: match profile.xrservice_branch.as_ref() { - Some(r) => r.clone(), - None => "main".into(), - }, + branch: profile + .xrservice_branch + .as_ref() + .unwrap_or(&"main".into()) + .clone(), }; jobs.extend(git.get_pre_build_jobs(profile.pull_on_build)); diff --git a/src/builders/build_opencomposite.rs b/src/builders/build_opencomposite.rs index 11553b3..bf45567 100644 --- a/src/builders/build_opencomposite.rs +++ b/src/builders/build_opencomposite.rs @@ -13,15 +13,17 @@ pub fn get_build_opencomposite_jobs(profile: &Profile, clean_build: bool) -> Vec let mut jobs = VecDeque::::new(); let git = Git { - repo: match profile.opencomposite_repo.as_ref() { - Some(r) => r.clone(), - None => "https://gitlab.com/znixian/OpenOVR.git".into(), - }, + repo: profile + .opencomposite_repo + .as_ref() + .unwrap_or(&"https://gitlab.com/znixian/OpenOVR.git".into()) + .clone(), dir: profile.opencomposite_path.clone(), - branch: match profile.opencomposite_branch.as_ref() { - Some(r) => r.clone(), - None => "openxr".into(), - }, + branch: profile + .opencomposite_branch + .as_ref() + .unwrap_or(&"openxr".into()) + .clone(), }; jobs.extend(git.get_pre_build_jobs(profile.pull_on_build)); diff --git a/src/builders/build_openhmd.rs b/src/builders/build_openhmd.rs index 322cf63..5fe612c 100644 --- a/src/builders/build_openhmd.rs +++ b/src/builders/build_openhmd.rs @@ -13,15 +13,21 @@ pub fn get_build_openhmd_jobs(profile: &Profile, clean_build: bool) -> VecDeque< let mut jobs = VecDeque::::new(); let git = Git { - repo: match profile.features.openhmd.repo.as_ref() { - Some(r) => r.clone(), - None => "https://github.com/OpenHMD/OpenHMD".into(), - }, + repo: profile + .features + .openhmd + .repo + .as_ref() + .unwrap_or(&"https://github.com/OpenHMD/OpenHMD".into()) + .clone(), dir: profile.features.openhmd.path.as_ref().unwrap().clone(), - branch: match profile.features.openhmd.branch.as_ref() { - Some(r) => r.clone(), - None => "master".into(), - }, + branch: profile + .features + .openhmd + .branch + .as_ref() + .unwrap_or(&"master".into()) + .clone(), }; jobs.extend(git.get_pre_build_jobs(profile.pull_on_build)); diff --git a/src/builders/build_wivrn.rs b/src/builders/build_wivrn.rs index 7c39591..52bfb66 100644 --- a/src/builders/build_wivrn.rs +++ b/src/builders/build_wivrn.rs @@ -13,15 +13,17 @@ pub fn get_build_wivrn_jobs(profile: &Profile, clean_build: bool) -> VecDeque::new(); let git = Git { - repo: match profile.xrservice_repo.as_ref() { - Some(r) => r.clone(), - None => "https://github.com/Meumeu/WiVRn".into(), - }, + repo: profile + .xrservice_repo + .as_ref() + .unwrap_or(&"https://github.com/Meumeu/WiVRn".into()) + .clone(), dir: profile.xrservice_path.clone(), - branch: match profile.xrservice_branch.as_ref() { - Some(r) => r.clone(), - None => "master".into(), - }, + branch: profile + .xrservice_branch + .as_ref() + .unwrap_or(&"master".into()) + .clone(), }; jobs.extend(git.get_pre_build_jobs(profile.pull_on_build));