From 81c2821c8c911418b2894cf51e5f5bb5407f176f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christina=20S=C3=B8rensen?= Date: Mon, 24 Jul 2023 07:36:21 +0200 Subject: [PATCH] refactor: code quality improvements MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Christina Sørensen --- src/git.rs | 20 ++++++++++---------- src/main.rs | 3 +-- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/src/git.rs b/src/git.rs index f9d49c2..3352bba 100644 --- a/src/git.rs +++ b/src/git.rs @@ -186,10 +186,10 @@ impl Repo { { // TODO: check if &self.name.as_ref() already exists in dir let output = Command::new("git") - .current_dir(&self.path.as_ref().unwrap()) + .current_dir(self.path.as_ref().unwrap()) .arg("clone") - .arg(&self.url.as_ref().unwrap()) - .arg(&self.name.as_ref().unwrap()) + .arg(self.url.as_ref().unwrap()) + .arg(self.name.as_ref().unwrap()) .output() .unwrap_or_else(|_| panic!("git repo failed to clone: {:?}", &self,)); output.status.success() @@ -618,7 +618,7 @@ impl Config { for category in self.categories.values() { // HACK: if the repo doesn't exist here, we inject tmp - for (_, repo) in category.repos.as_ref().unwrap_or_else(|| &tmp).iter() { + for (_, repo) in category.repos.as_ref().unwrap_or(&tmp).iter() { use RepoKinds::*; match &repo.kind { Some(GitRepo) => { @@ -650,10 +650,10 @@ impl Config { } } None => { - println!("unknown kind {:?}", repo.kind) + println!("unknown kind {:?}", repo.kind); } Some(kind) => { - println!("unknown kind {kind:?}") + println!("unknown kind {kind:?}"); } } } @@ -663,7 +663,7 @@ impl Config { where F: FnOnce(&Repo), { - f(&self + f(self .categories .get(cat_name) .expect("failed to get category") @@ -671,13 +671,13 @@ impl Config { .as_ref() .expect("failed to get repo") .get(repo_name) - .expect("failed to get category")) + .expect("failed to get category")); } pub fn get_link(&self, cat_name: &str, link_name: &str, f: F) where F: FnOnce(&Link), { - f(&self + f(self .categories .get(cat_name) .expect("failed to get category") @@ -685,7 +685,7 @@ impl Config { .as_ref() .expect("failed to get repo") .get(link_name) - .expect("failed to get category")) + .expect("failed to get category")); } /// Tries to pull all repositories, skips if fail. pub fn pull_all(&self) { diff --git a/src/main.rs b/src/main.rs index 6a6dc5f..100efe1 100644 --- a/src/main.rs +++ b/src/main.rs @@ -45,7 +45,6 @@ mod utils; use cli::{Args, Commands, JumpCommands}; use git::Config; -use utils::strings::{FAST_COMMIT, QUICK_COMMIT}; use clap::Parser; @@ -65,7 +64,7 @@ fn main() { // Input from -m flag is stored here, this is just used to construct the // persistent box - let mut message_input: String = "".to_string(); + let mut message_input: String = String::new(); match &args { args if args.license => println!("{}", utils::strings::INTERACTIVE_LICENSE),