From 3c8a635a11d994d95cfb5f4acf72ee7f283477f5 Mon Sep 17 00:00:00 2001 From: Santhosh Chinnasamy Date: Sat, 12 Oct 2024 13:07:32 +0530 Subject: [PATCH] add clippy fixes --- src/alias.rs | 16 ++++++++-------- src/browser.rs | 2 +- src/commands/git.rs | 8 ++++---- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/alias.rs b/src/alias.rs index fb9df52..3fc00eb 100644 --- a/src/alias.rs +++ b/src/alias.rs @@ -2,9 +2,9 @@ use std::{fs, process::exit}; use toml::Table; -const CONFIG_FOLDER: &'static str = ".config/cliq"; -const CONFIG_FILE: &'static str = "cliq.toml"; -const DEFAULT_CONFIG: &'static str = " +const CONFIG_FOLDER: &str = ".config/cliq"; +const CONFIG_FILE: &str = "cliq.toml"; +const DEFAULT_CONFIG: &str = " [links] google = \"https://google.com\" hub = \"https://github.com\" @@ -14,7 +14,7 @@ lab = \"https://gitlab.com\" fn config_file() -> String { let home_dir = dirs::home_dir().unwrap().to_str().unwrap().to_string(); let cliq_config = format!("{}/{}/{}", home_dir, CONFIG_FOLDER, CONFIG_FILE); - return cliq_config.to_string(); + cliq_config.to_string() } fn create_config() { @@ -35,7 +35,7 @@ fn read_config() -> Table { create_config(); } - let cliq_config = match fs::read_to_string(&config_file()) { + let cliq_config = match fs::read_to_string(config_file()) { Ok(file) => file, Err(e) => { eprintln!("Error reading cliq.toml. \nCreate cliq.toml file under $HOME/.config/cliq folder. {}", e); @@ -44,13 +44,13 @@ fn read_config() -> Table { }; let cliq_data: Table = cliq_config.parse().unwrap(); - return cliq_data; + cliq_data } pub fn links() -> Table { let cliq_data = read_config(); let links = cliq_data["links"].as_table().unwrap().clone(); - return links; + links } pub fn link(alias: String) -> String { @@ -63,5 +63,5 @@ pub fn link(alias: String) -> String { } }; - return link.to_string(); + link.to_string() } diff --git a/src/browser.rs b/src/browser.rs index 5736ad4..6244c04 100644 --- a/src/browser.rs +++ b/src/browser.rs @@ -10,7 +10,7 @@ fn program() -> String { _ => LINUX, }; - return _program.to_string(); + _program.to_string() } pub fn open(url: String) { diff --git a/src/commands/git.rs b/src/commands/git.rs index ee4cc5f..7714b61 100644 --- a/src/commands/git.rs +++ b/src/commands/git.rs @@ -95,7 +95,7 @@ fn get_current_branch() -> String { .unwrap(); let branch = str::from_utf8(&result.stdout[..]).unwrap().to_string(); - return branch; + branch } fn get_current_tag_name() -> String { @@ -108,7 +108,7 @@ fn get_current_tag_name() -> String { .unwrap(); let tag = str::from_utf8(&result.stdout[..]).unwrap().to_string(); - return tag; + tag } fn get_current_commit_sha() -> String { @@ -121,7 +121,7 @@ fn get_current_commit_sha() -> String { .unwrap(); let commit_sha = str::from_utf8(&result.stdout[..]).unwrap().to_string(); - return commit_sha; + commit_sha } fn get_branch_or_tag_or_commit() -> String { @@ -130,7 +130,7 @@ fn get_branch_or_tag_or_commit() -> String { let commit = get_current_commit_sha(); if !branch.is_empty() { - return branch; + branch } else if !tag.is_empty() { return tag; } else if !commit.is_empty() {