From 5e7b24abe8d8e16286bfb5bd3cd1c60ac4cbb59e Mon Sep 17 00:00:00 2001 From: Denis Isidoro Date: Sat, 7 Aug 2021 07:05:33 -0300 Subject: [PATCH] Fix clippy warnings --- src/actor.rs | 2 +- src/config/cli.rs | 8 ++++---- src/config/yaml.rs | 2 +- src/finder/post.rs | 2 +- src/handler/core.rs | 2 +- src/parser.rs | 2 +- src/shell.rs | 4 ++-- src/structures/cheat.rs | 2 +- src/tldr.rs | 2 +- src/welcome.rs | 2 +- 10 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/actor.rs b/src/actor.rs index dc6fe7a..cce0626 100644 --- a/src/actor.rs +++ b/src/actor.rs @@ -165,7 +165,7 @@ fn replace_variables_from_snippet(snippet: &str, tags: &str, variables: Variable let value = if let Ok(e) = env_value { e - } else if let Some(suggestion) = variables.get_suggestion(&tags, &variable_name) { + } else if let Some(suggestion) = variables.get_suggestion(tags, variable_name) { let mut new_suggestion = suggestion.clone(); new_suggestion.0 = replace_variables_from_snippet(&new_suggestion.0, tags, variables.clone())?; prompt_finder(variable_name, Some(&new_suggestion), variable_count)? diff --git a/src/config/cli.rs b/src/config/cli.rs index 3ee708d..433c71a 100644 --- a/src/config/cli.rs +++ b/src/config/cli.rs @@ -8,10 +8,10 @@ use clap::{crate_version, AppSettings, Clap}; use std::str::FromStr; -const FINDER_POSSIBLE_VALUES: &[&str] = &[&"fzf", &"skim"]; -const WIDGET_POSSIBLE_VALUES: &[&str] = &[&"bash", &"zsh", &"fish"]; -const FUNC_POSSIBLE_VALUES: &[&str] = &[&"url::open", &"welcome", &"widget::last_command", &"map::expand"]; -const INFO_POSSIBLE_VALUES: &[&str] = &[&"cheats-path", "config-path", "config-example"]; +const FINDER_POSSIBLE_VALUES: &[&str] = &["fzf", "skim"]; +const WIDGET_POSSIBLE_VALUES: &[&str] = &["bash", "zsh", "fish"]; +const FUNC_POSSIBLE_VALUES: &[&str] = &["url::open", "welcome", "widget::last_command", "map::expand"]; +const INFO_POSSIBLE_VALUES: &[&str] = &["cheats-path", "config-path", "config-example"]; impl FromStr for Shell { type Err = &'static str; diff --git a/src/config/yaml.rs b/src/config/yaml.rs index e211d8c..41f821e 100644 --- a/src/config/yaml.rs +++ b/src/config/yaml.rs @@ -93,7 +93,7 @@ pub struct YamlConfig { impl YamlConfig { fn from_str(text: &str) -> Result { - serde_yaml::from_str(&text).map_err(|e| e.into()) + serde_yaml::from_str(text).map_err(|e| e.into()) } fn from_path(path: &Path) -> Result { diff --git a/src/finder/post.rs b/src/finder/post.rs index 92bd322..4ddbe0e 100644 --- a/src/finder/post.rs +++ b/src/finder/post.rs @@ -40,7 +40,7 @@ fn get_column(text: String, column: Option, delimiter: Option<&str>) -> Stri let mut result = String::from(""); let re = regex::Regex::new(delimiter.unwrap_or(r"\s\s+")).expect("Invalid regex"); for line in text.split('\n') { - if (&line).is_empty() { + if (line).is_empty() { continue; } let mut parts = re.split(line).skip((c - 1) as usize); diff --git a/src/handler/core.rs b/src/handler/core.rs index 508ccdf..ff8ba67 100644 --- a/src/handler/core.rs +++ b/src/handler/core.rs @@ -15,7 +15,7 @@ use anyhow::Result; pub fn main() -> Result<()> { let config = &CONFIG; - let opts = FinderOpts::from_config(&config)?; + let opts = FinderOpts::from_config(config)?; let (raw_selection, variables, files) = config .finder() diff --git a/src/parser.rs b/src/parser.rs index 11ca591..3e2ddc1 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -206,7 +206,7 @@ pub fn read_lines( id ) })?; - variables.insert_suggestion(&item.tags, &variable, (String::from(command), opts)); + variables.insert_suggestion(&item.tags, variable, (String::from(command), opts)); } // snippet else { diff --git a/src/shell.rs b/src/shell.rs index 5752f9c..e82376c 100644 --- a/src/shell.rs +++ b/src/shell.rs @@ -70,8 +70,8 @@ pub fn widget_last_command() -> Result<()> { } for (pattern, escaped) in replacements.clone() { - text = text.replace(&escaped, &pattern); - extracted = extracted.replace(&escaped, &pattern); + text = text.replace(&escaped, pattern); + extracted = extracted.replace(&escaped, pattern); } println!("{}", extracted.trim_start()); diff --git a/src/structures/cheat.rs b/src/structures/cheat.rs index 1a60bb4..d4ce57c 100644 --- a/src/structures/cheat.rs +++ b/src/structures/cheat.rs @@ -52,7 +52,7 @@ impl VariableMap { if let Some(dependency_keys) = self.dependencies.get(&k) { for dependency_key in dependency_keys { - if let Some(vm) = self.variables.get(&dependency_key) { + if let Some(vm) = self.variables.get(dependency_key) { let res = vm.get(variable); if res.is_some() { return res; diff --git a/src/tldr.rs b/src/tldr.rs index f5fe0bc..adbf5da 100644 --- a/src/tldr.rs +++ b/src/tldr.rs @@ -16,7 +16,7 @@ static VERSION_DISCLAIMER: &str = "The tldr client written in C (the default one The client written in Rust is recommended. The one available in npm works, too."; fn convert_tldr_vars(line: &str) -> String { - let caps = VAR_TLDR_REGEX.find_iter(&line); + let caps = VAR_TLDR_REGEX.find_iter(line); let mut new_line: String = line.to_string(); for cap in caps { let braced_var = cap.as_str(); diff --git a/src/welcome.rs b/src/welcome.rs index 109588c..c4920f8 100644 --- a/src/welcome.rs +++ b/src/welcome.rs @@ -12,7 +12,7 @@ use std::io::Write; pub fn main() -> Result<()> { let config = &CONFIG; - let opts = FinderOpts::from_config(&config)?; + let opts = FinderOpts::from_config(config)?; let (raw_selection, variables, files) = config .finder() .call(opts, |stdin, _| {