From 1c955fb74f47a1d19160fc28616f445d606827e0 Mon Sep 17 00:00:00 2001 From: Federico Terzi Date: Wed, 24 Aug 2022 20:29:26 +0200 Subject: [PATCH] fix(misc): fix clippy warnings --- espanso-config/src/error.rs | 2 +- espanso-config/src/legacy/config.rs | 4 +-- espanso-config/src/legacy/model.rs | 2 +- .../src/matches/group/loader/yaml/parse.rs | 2 +- espanso-config/src/matches/store/mod.rs | 2 +- espanso-detect/src/event.rs | 16 ++++++------ espanso-detect/src/hotkey/keys.rs | 2 +- espanso-detect/src/hotkey/mod.rs | 2 +- espanso-engine/src/event/effect.rs | 6 ++--- espanso-engine/src/event/external.rs | 2 +- espanso-engine/src/event/input.rs | 16 ++++++------ espanso-engine/src/event/internal.rs | 26 +++++++++---------- espanso-engine/src/event/ui.rs | 8 +++--- .../src/process/middleware/matcher.rs | 4 +-- espanso-match/src/event.rs | 2 +- espanso-match/src/rolling/mod.rs | 4 +-- espanso-modulo/build.rs | 2 +- espanso-modulo/src/form/parser/layout.rs | 2 +- espanso-modulo/src/search/algorithm.rs | 13 ++++------ espanso-modulo/src/sys/search/mod.rs | 9 +++---- espanso-modulo/src/troubleshooting.rs | 4 ++- espanso-package/src/archive/mod.rs | 8 +++--- espanso-package/src/manifest.rs | 2 +- espanso-package/src/resolver.rs | 2 +- espanso-package/src/util/download.rs | 2 +- espanso-package/src/util/github.rs | 2 +- espanso-package/src/util/gitlab.rs | 2 +- espanso-render/src/extension/script.rs | 9 +++---- espanso-render/src/lib.rs | 6 ++--- espanso-render/src/renderer/util.rs | 2 +- espanso-ui/src/event.rs | 2 +- espanso/src/cli/mod.rs | 2 +- 32 files changed, 82 insertions(+), 87 deletions(-) diff --git a/espanso-config/src/error.rs b/espanso-config/src/error.rs index d376013..e2b812b 100644 --- a/espanso-config/src/error.rs +++ b/espanso-config/src/error.rs @@ -64,7 +64,7 @@ impl ErrorRecord { } } -#[derive(Debug, PartialEq)] +#[derive(Debug, PartialEq, Eq)] pub enum ErrorLevel { Error, Warning, diff --git a/espanso-config/src/legacy/config.rs b/espanso-config/src/legacy/config.rs index a873744..5bb5748 100644 --- a/espanso-config/src/legacy/config.rs +++ b/espanso-config/src/legacy/config.rs @@ -386,7 +386,7 @@ impl LegacyConfig { } } -#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] +#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Eq)] pub enum BackendType { Inject, Clipboard, @@ -740,7 +740,7 @@ impl LegacyConfigSet { } // Error handling -#[derive(Debug, PartialEq)] +#[derive(Debug, PartialEq, Eq)] #[allow(dead_code)] pub enum ConfigLoadError { FileNotFound, diff --git a/espanso-config/src/legacy/model.rs b/espanso-config/src/legacy/model.rs index 4427deb..698ca52 100644 --- a/espanso-config/src/legacy/model.rs +++ b/espanso-config/src/legacy/model.rs @@ -21,7 +21,7 @@ use serde::{Deserialize, Serialize}; #[allow(non_camel_case_types)] #[allow(clippy::upper_case_acronyms)] -#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] +#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Eq)] pub enum KeyModifier { CTRL, SHIFT, diff --git a/espanso-config/src/matches/group/loader/yaml/parse.rs b/espanso-config/src/matches/group/loader/yaml/parse.rs index bcdfe18..32c752a 100644 --- a/espanso-config/src/matches/group/loader/yaml/parse.rs +++ b/espanso-config/src/matches/group/loader/yaml/parse.rs @@ -119,7 +119,7 @@ pub struct YAMLMatch { pub search_terms: Option>, } -#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)] +#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Eq)] pub struct YAMLVariable { pub name: String, diff --git a/espanso-config/src/matches/store/mod.rs b/espanso-config/src/matches/store/mod.rs index 2c252fa..64202e9 100644 --- a/espanso-config/src/matches/store/mod.rs +++ b/espanso-config/src/matches/store/mod.rs @@ -28,7 +28,7 @@ pub trait MatchStore: Send { fn loaded_paths(&self) -> Vec; } -#[derive(Debug, Clone, PartialEq)] +#[derive(Debug, Clone, PartialEq, Eq)] pub struct MatchSet<'a> { pub matches: Vec<&'a Match>, pub global_vars: Vec<&'a Variable>, diff --git a/espanso-detect/src/event.rs b/espanso-detect/src/event.rs index 30090c5..c645e84 100644 --- a/espanso-detect/src/event.rs +++ b/espanso-detect/src/event.rs @@ -19,7 +19,7 @@ #[cfg(test)] use enum_as_inner::EnumAsInner; -#[derive(Debug, PartialEq)] +#[derive(Debug, PartialEq, Eq)] #[cfg_attr(test, derive(EnumAsInner))] pub enum InputEvent { Mouse(MouseEvent), @@ -32,7 +32,7 @@ pub enum InputEvent { AllModifiersReleased, } -#[derive(Debug, PartialEq)] +#[derive(Debug, PartialEq, Eq)] pub enum MouseButton { Left, Right, @@ -44,25 +44,25 @@ pub enum MouseButton { Button5, } -#[derive(Debug, PartialEq)] +#[derive(Debug, PartialEq, Eq)] pub struct MouseEvent { pub button: MouseButton, pub status: Status, } -#[derive(Debug, PartialEq)] +#[derive(Debug, PartialEq, Eq)] pub enum Status { Pressed, Released, } -#[derive(Debug, PartialEq)] +#[derive(Debug, PartialEq, Eq)] pub enum Variant { Left, Right, } -#[derive(Debug, PartialEq)] +#[derive(Debug, PartialEq, Eq)] pub struct KeyboardEvent { pub key: Key, pub value: Option, @@ -72,7 +72,7 @@ pub struct KeyboardEvent { } // A subset of the Web's key values: https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key/Key_Values -#[derive(Debug, PartialEq)] +#[derive(Debug, PartialEq, Eq)] pub enum Key { // Modifiers Alt, @@ -141,7 +141,7 @@ pub enum Key { Other(i32), } -#[derive(Debug, PartialEq)] +#[derive(Debug, PartialEq, Eq)] pub struct HotKeyEvent { pub hotkey_id: i32, } diff --git a/espanso-detect/src/hotkey/keys.rs b/espanso-detect/src/hotkey/keys.rs index fa1ccf7..c033faf 100644 --- a/espanso-detect/src/hotkey/keys.rs +++ b/espanso-detect/src/hotkey/keys.rs @@ -25,7 +25,7 @@ lazy_static! { static ref RAW_PARSER: Regex = Regex::new(r"^RAW\((\d+)\)$").unwrap(); } -#[derive(Debug, PartialEq, Clone)] +#[derive(Debug, PartialEq, Clone, Eq)] pub enum ShortcutKey { Alt, Control, diff --git a/espanso-detect/src/hotkey/mod.rs b/espanso-detect/src/hotkey/mod.rs index d08440b..1534a13 100644 --- a/espanso-detect/src/hotkey/mod.rs +++ b/espanso-detect/src/hotkey/mod.rs @@ -32,7 +32,7 @@ static MODIFIERS: &[ShortcutKey; 4] = &[ ShortcutKey::Meta, ]; -#[derive(Debug, PartialEq, Clone)] +#[derive(Debug, PartialEq, Clone, Eq)] pub struct HotKey { pub id: i32, pub key: ShortcutKey, diff --git a/espanso-engine/src/event/effect.rs b/espanso-engine/src/event/effect.rs index 48314c1..56748f2 100644 --- a/espanso-engine/src/event/effect.rs +++ b/espanso-engine/src/event/effect.rs @@ -19,13 +19,13 @@ use super::input::Key; -#[derive(Debug, Clone, PartialEq)] +#[derive(Debug, Clone, PartialEq, Eq)] pub struct TriggerCompensationEvent { pub trigger: String, pub left_separator: Option, } -#[derive(Debug, Clone, PartialEq)] +#[derive(Debug, Clone, PartialEq, Eq)] pub struct CursorHintCompensationEvent { pub cursor_hint_back_count: usize, } @@ -46,7 +46,7 @@ pub struct HtmlInjectRequest { pub html: String, } -#[derive(Debug, PartialEq, Clone)] +#[derive(Debug, PartialEq, Clone, Eq)] pub enum TextInjectMode { Keys, Clipboard, diff --git a/espanso-engine/src/event/external.rs b/espanso-engine/src/event/external.rs index 91ae9d1..ffe80a9 100644 --- a/espanso-engine/src/event/external.rs +++ b/espanso-engine/src/event/external.rs @@ -19,7 +19,7 @@ use std::collections::HashMap; -#[derive(Debug, Clone, PartialEq)] +#[derive(Debug, Clone, PartialEq, Eq)] pub struct MatchExecRequestEvent { pub trigger: Option, pub args: HashMap, diff --git a/espanso-engine/src/event/input.rs b/espanso-engine/src/event/input.rs index fc22cf5..3577011 100644 --- a/espanso-engine/src/event/input.rs +++ b/espanso-engine/src/event/input.rs @@ -17,19 +17,19 @@ * along with espanso. If not, see . */ -#[derive(Debug, PartialEq, Clone)] +#[derive(Debug, PartialEq, Clone, Eq)] pub enum Status { Pressed, Released, } -#[derive(Debug, PartialEq, Clone)] +#[derive(Debug, PartialEq, Clone, Eq)] pub enum Variant { Left, Right, } -#[derive(Debug, PartialEq, Clone)] +#[derive(Debug, PartialEq, Clone, Eq)] pub struct KeyboardEvent { pub key: Key, pub value: Option, @@ -37,7 +37,7 @@ pub struct KeyboardEvent { pub variant: Option, } -#[derive(Debug, Clone, PartialEq)] +#[derive(Debug, Clone, PartialEq, Eq)] pub enum MouseButton { Left, Right, @@ -49,13 +49,13 @@ pub enum MouseButton { Button5, } -#[derive(Debug, Clone, PartialEq)] +#[derive(Debug, Clone, PartialEq, Eq)] pub struct MouseEvent { pub button: MouseButton, pub status: Status, } -#[derive(Debug, Clone, PartialEq)] +#[derive(Debug, Clone, PartialEq, Eq)] pub enum Key { // Modifiers Alt, @@ -124,12 +124,12 @@ pub enum Key { Other(i32), } -#[derive(Debug, Clone, PartialEq)] +#[derive(Debug, Clone, PartialEq, Eq)] pub struct ContextMenuClickedEvent { pub context_item_id: u32, } -#[derive(Debug, Clone, PartialEq)] +#[derive(Debug, Clone, PartialEq, Eq)] pub struct HotKeyEvent { pub hotkey_id: i32, } diff --git a/espanso-engine/src/event/internal.rs b/espanso-engine/src/event/internal.rs index eac56a3..aa5b5fd 100644 --- a/espanso-engine/src/event/internal.rs +++ b/espanso-engine/src/event/internal.rs @@ -19,13 +19,13 @@ use std::collections::HashMap; -#[derive(Debug, Clone, PartialEq)] +#[derive(Debug, Clone, PartialEq, Eq)] pub struct MatchesDetectedEvent { pub matches: Vec, pub is_search: bool, } -#[derive(Debug, Clone, PartialEq, Default)] +#[derive(Debug, Clone, PartialEq, Default, Eq)] pub struct DetectedMatch { pub id: i32, pub trigger: Option, @@ -34,17 +34,17 @@ pub struct DetectedMatch { pub args: HashMap, } -#[derive(Debug, Clone, PartialEq)] +#[derive(Debug, Clone, PartialEq, Eq)] pub struct MatchSelectedEvent { pub chosen: DetectedMatch, } -#[derive(Debug, Clone, PartialEq)] +#[derive(Debug, Clone, PartialEq, Eq)] pub struct CauseCompensatedMatchEvent { pub m: DetectedMatch, } -#[derive(Debug, Clone, PartialEq)] +#[derive(Debug, Clone, PartialEq, Eq)] pub struct RenderingRequestedEvent { pub match_id: i32, pub trigger: Option, @@ -54,38 +54,38 @@ pub struct RenderingRequestedEvent { pub format: TextFormat, } -#[derive(Debug, Clone, PartialEq)] +#[derive(Debug, Clone, PartialEq, Eq)] pub enum TextFormat { Plain, Markdown, Html, } -#[derive(Debug, Clone, PartialEq)] +#[derive(Debug, Clone, PartialEq, Eq)] pub struct ImageRequestedEvent { pub match_id: i32, pub image_path: String, } -#[derive(Debug, Clone, PartialEq)] +#[derive(Debug, Clone, PartialEq, Eq)] pub struct ImageResolvedEvent { pub image_path: String, } -#[derive(Debug, Clone, PartialEq)] +#[derive(Debug, Clone, PartialEq, Eq)] pub struct RenderedEvent { pub match_id: i32, pub body: String, pub format: TextFormat, } -#[derive(Debug, Clone, PartialEq)] +#[derive(Debug, Clone, PartialEq, Eq)] pub struct DiscardPreviousEvent { // All Events with a source_id smaller than this one will be discarded pub minimum_source_id: u32, } -#[derive(Debug, Clone, PartialEq)] +#[derive(Debug, Clone, PartialEq, Eq)] pub struct DiscardBetweenEvent { // All Events with a source_id between start_id (included) and end_id (excluded) // will be discarded @@ -93,13 +93,13 @@ pub struct DiscardBetweenEvent { pub end_id: u32, } -#[derive(Debug, Clone, PartialEq)] +#[derive(Debug, Clone, PartialEq, Eq)] pub struct SecureInputEnabledEvent { pub app_name: String, pub app_path: String, } -#[derive(Debug, Clone, PartialEq)] +#[derive(Debug, Clone, PartialEq, Eq)] pub struct UndoEvent { pub match_id: i32, pub trigger: String, diff --git a/espanso-engine/src/event/ui.rs b/espanso-engine/src/event/ui.rs index f23bbb9..f921050 100644 --- a/espanso-engine/src/event/ui.rs +++ b/espanso-engine/src/event/ui.rs @@ -29,7 +29,7 @@ pub enum MenuItem { Separator, } -#[derive(Debug, Clone, PartialEq)] +#[derive(Debug, Clone, PartialEq, Eq)] pub struct SimpleMenuItem { pub id: u32, pub label: String, @@ -41,19 +41,19 @@ pub struct SubMenuItem { pub items: Vec, } -#[derive(Debug, Clone, PartialEq)] +#[derive(Debug, Clone, PartialEq, Eq)] pub struct IconStatusChangeEvent { pub status: IconStatus, } -#[derive(Debug, Clone, PartialEq)] +#[derive(Debug, Clone, PartialEq, Eq)] pub enum IconStatus { Enabled, Disabled, SecureInputDisabled, } -#[derive(Debug, Clone, PartialEq)] +#[derive(Debug, Clone, PartialEq, Eq)] pub struct ShowTextEvent { pub title: String, pub text: String, diff --git a/espanso-engine/src/process/middleware/matcher.rs b/espanso-engine/src/process/middleware/matcher.rs index d16276d..8692a3b 100644 --- a/espanso-engine/src/process/middleware/matcher.rs +++ b/espanso-engine/src/process/middleware/matcher.rs @@ -44,7 +44,7 @@ pub enum MatcherEvent { VirtualSeparator, } -#[derive(Debug, Clone, PartialEq)] +#[derive(Debug, Clone, PartialEq, Eq)] pub struct MatchResult { pub id: i32, pub trigger: String, @@ -104,7 +104,7 @@ impl<'a, State> Middleware for MatcherMiddleware<'a, State> { if is_event_of_interest(&event.etype) { let mut matcher_states = self.matcher_states.borrow_mut(); let prev_states = if !matcher_states.is_empty() { - matcher_states.get(matcher_states.len() - 1) + matcher_states.back() } else { None }; diff --git a/espanso-match/src/event.rs b/espanso-match/src/event.rs index b01d5a5..75e37a1 100644 --- a/espanso-match/src/event.rs +++ b/espanso-match/src/event.rs @@ -17,7 +17,7 @@ * along with espanso. If not, see . */ -#[derive(Debug, Clone, PartialEq)] +#[derive(Debug, Clone, PartialEq, Eq)] pub enum Event { Key { key: Key, chars: Option }, VirtualSeparator, diff --git a/espanso-match/src/rolling/mod.rs b/espanso-match/src/rolling/mod.rs index ec2db0e..c0713a2 100644 --- a/espanso-match/src/rolling/mod.rs +++ b/espanso-match/src/rolling/mod.rs @@ -23,7 +23,7 @@ pub mod matcher; mod tree; mod util; -#[derive(Debug, Clone, PartialEq)] +#[derive(Debug, Clone, PartialEq, Eq)] pub enum RollingItem { WordSeparator, Key(Key), @@ -31,7 +31,7 @@ pub enum RollingItem { CharInsensitive(String), } -#[derive(Debug, PartialEq)] +#[derive(Debug, PartialEq, Eq)] pub struct RollingMatch { pub id: Id, pub items: Vec, diff --git a/espanso-modulo/build.rs b/espanso-modulo/build.rs index b8b889a..3fbb684 100644 --- a/espanso-modulo/build.rs +++ b/espanso-modulo/build.rs @@ -90,7 +90,7 @@ fn build_native() { ) .args(&[ "/k", - &vcvars_path.to_string_lossy().to_string(), + &vcvars_path.to_string_lossy(), "&", "nmake", "/f", diff --git a/espanso-modulo/src/form/parser/layout.rs b/espanso-modulo/src/form/parser/layout.rs index 4336b1e..9a706a5 100644 --- a/espanso-modulo/src/form/parser/layout.rs +++ b/espanso-modulo/src/form/parser/layout.rs @@ -25,7 +25,7 @@ lazy_static! { static ref FIELD_REGEX: Regex = Regex::new(r"\{\{(.*?)\}\}|\[\[(.*?)\]\]").unwrap(); } -#[derive(Debug, Clone, PartialEq)] +#[derive(Debug, Clone, PartialEq, Eq)] pub enum Token { Text(String), // Text Field(String), // id: String diff --git a/espanso-modulo/src/search/algorithm.rs b/espanso-modulo/src/search/algorithm.rs index 9faf0be..8c90e6e 100644 --- a/espanso-modulo/src/search/algorithm.rs +++ b/espanso-modulo/src/search/algorithm.rs @@ -21,11 +21,10 @@ use std::collections::HashSet; use crate::sys::search::types::SearchItem; -pub fn get_algorithm( - name: &str, - use_command_filter: bool, -) -> Box Vec> { - let search_algorithm: Box Vec> = match name { +type FilterCallback = dyn Fn(&str, &[SearchItem]) -> Vec; + +pub fn get_algorithm(name: &str, use_command_filter: bool) -> Box { + let search_algorithm: Box = match name { "exact" => Box::new(exact_match), "iexact" => Box::new(case_insensitive_exact_match), "ikey" => Box::new(case_insensitive_keyword), @@ -100,9 +99,7 @@ fn case_insensitive_keyword(query: &str, items: &[SearchItem]) -> Vec { .collect() } -fn command_filter( - search_algorithm: Box Vec>, -) -> Box Vec> { +fn command_filter(search_algorithm: Box) -> Box { Box::new(move |query, items| { let (valid_ids, trimmed_query) = if query.starts_with('>') { ( diff --git a/espanso-modulo/src/sys/search/mod.rs b/espanso-modulo/src/sys/search/mod.rs index 6ed1efe..ab0021f 100644 --- a/espanso-modulo/src/sys/search/mod.rs +++ b/espanso-modulo/src/sys/search/mod.rs @@ -147,16 +147,15 @@ mod interop { } } +type SearchAlgorithmCallback = dyn Fn(&str, &[types::SearchItem]) -> Vec; + struct SearchData { owned_search: interop::OwnedSearch, items: Vec, - algorithm: Box Vec>, + algorithm: Box, } -pub fn show( - search: types::Search, - algorithm: Box Vec>, -) -> Option { +pub fn show(search: types::Search, algorithm: Box) -> Option { use super::interop::*; let owned_search: interop::OwnedSearch = (&search).into(); diff --git a/espanso-modulo/src/troubleshooting.rs b/espanso-modulo/src/troubleshooting.rs index b19dc7d..f92c094 100644 --- a/espanso-modulo/src/troubleshooting.rs +++ b/espanso-modulo/src/troubleshooting.rs @@ -44,7 +44,9 @@ pub enum ErrorLevel { Warning, } +type OpenFileCallback = dyn Fn(&Path) + Send; + pub struct TroubleshootingHandlers { pub dont_show_again_changed: Option>, - pub open_file: Option>, + pub open_file: Option>, } diff --git a/espanso-package/src/archive/mod.rs b/espanso-package/src/archive/mod.rs index 62ae7df..aa59cce 100644 --- a/espanso-package/src/archive/mod.rs +++ b/espanso-package/src/archive/mod.rs @@ -30,7 +30,7 @@ mod util; pub const PACKAGE_SOURCE_FILE: &str = "_pkgsource.yml"; -#[derive(Debug, PartialEq)] +#[derive(Debug, PartialEq, Eq)] pub struct ArchivedPackage { // Metadata pub manifest: Manifest, @@ -39,12 +39,12 @@ pub struct ArchivedPackage { pub source: PackageSource, } -#[derive(Debug, PartialEq)] +#[derive(Debug, PartialEq, Eq)] pub struct LegacyPackage { pub name: String, } -#[derive(Debug, PartialEq)] +#[derive(Debug, PartialEq, Eq)] pub enum StoredPackage { Legacy(LegacyPackage), Modern(ArchivedPackage), @@ -67,7 +67,7 @@ pub struct SaveOptions { pub overwrite_existing: bool, } -#[derive(Debug, Serialize, Deserialize, PartialEq)] +#[derive(Debug, Serialize, Deserialize, PartialEq, Eq)] #[serde(rename_all = "snake_case")] pub enum PackageSource { Hub, diff --git a/espanso-package/src/manifest.rs b/espanso-package/src/manifest.rs index b6ff60f..e1406cd 100644 --- a/espanso-package/src/manifest.rs +++ b/espanso-package/src/manifest.rs @@ -22,7 +22,7 @@ use std::path::Path; use anyhow::{Context, Result}; use serde::{Deserialize, Serialize}; -#[derive(Debug, PartialEq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Serialize, Deserialize, Eq)] pub struct Manifest { pub name: String, pub title: String, diff --git a/espanso-package/src/resolver.rs b/espanso-package/src/resolver.rs index ceab97b..49c4801 100644 --- a/espanso-package/src/resolver.rs +++ b/espanso-package/src/resolver.rs @@ -23,7 +23,7 @@ use anyhow::{anyhow, bail, Context, Result}; use crate::manifest::Manifest; -#[derive(Debug, PartialEq)] +#[derive(Debug, PartialEq, Eq)] pub struct ResolvedPackage { pub manifest: Manifest, pub base_dir: PathBuf, diff --git a/espanso-package/src/util/download.rs b/espanso-package/src/util/download.rs index 45258a2..b1a3089 100644 --- a/espanso-package/src/util/download.rs +++ b/espanso-package/src/util/download.rs @@ -82,7 +82,7 @@ fn extract_zip(data: Vec, dest_dir: &Path) -> Result<()> { None => continue, }; - if (&*file.name()).ends_with('/') { + if file.name().ends_with('/') { std::fs::create_dir_all(&outpath)?; } else { if let Some(p) = outpath.parent() { diff --git a/espanso-package/src/util/github.rs b/espanso-package/src/util/github.rs index 69cbf8f..8528a51 100644 --- a/espanso-package/src/util/github.rs +++ b/espanso-package/src/util/github.rs @@ -28,7 +28,7 @@ lazy_static! { .unwrap(); } -#[derive(Debug, PartialEq)] +#[derive(Debug, PartialEq, Eq)] pub struct GitHubParts { author: String, name: String, diff --git a/espanso-package/src/util/gitlab.rs b/espanso-package/src/util/gitlab.rs index dbe15b7..66a2239 100644 --- a/espanso-package/src/util/gitlab.rs +++ b/espanso-package/src/util/gitlab.rs @@ -28,7 +28,7 @@ lazy_static! { .unwrap(); } -#[derive(Debug, PartialEq)] +#[derive(Debug, PartialEq, Eq)] pub struct GitLabParts { author: String, name: String, diff --git a/espanso-render/src/extension/script.rs b/espanso-render/src/extension/script.rs index a59c38b..663f737 100644 --- a/espanso-render/src/extension/script.rs +++ b/espanso-render/src/extension/script.rs @@ -66,16 +66,13 @@ impl Extension for ScriptExtension { // Also replace %CONFIG% and %PACKAGES% path. See issue #380 args.iter_mut().for_each(|arg| { if arg.contains("%HOME%") { - *arg = arg.replace("%HOME%", &self.home_path.to_string_lossy().to_string()); + *arg = arg.replace("%HOME%", &self.home_path.to_string_lossy()); } if arg.contains("%CONFIG%") { - *arg = arg.replace("%CONFIG%", &self.config_path.to_string_lossy().to_string()); + *arg = arg.replace("%CONFIG%", &self.config_path.to_string_lossy()); } if arg.contains("%PACKAGES%") { - *arg = arg.replace( - "%PACKAGES%", - &self.packages_path.to_string_lossy().to_string(), - ); + *arg = arg.replace("%PACKAGES%", &self.packages_path.to_string_lossy()); } // On Windows, correct paths separators diff --git a/espanso-render/src/lib.rs b/espanso-render/src/lib.rs index 29296ce..8d42cb2 100644 --- a/espanso-render/src/lib.rs +++ b/espanso-render/src/lib.rs @@ -48,7 +48,7 @@ pub struct Context<'a> { pub templates: Vec<&'a Template>, } -#[derive(Debug, Clone, PartialEq)] +#[derive(Debug, Clone, PartialEq, Eq)] pub struct RenderOptions { pub casing_style: CasingStyle, } @@ -61,7 +61,7 @@ impl Default for RenderOptions { } } -#[derive(Debug, Clone, PartialEq)] +#[derive(Debug, Clone, PartialEq, Eq)] pub enum CasingStyle { None, Capitalize, @@ -123,7 +123,7 @@ pub trait Extension { pub type Scope<'a> = HashMap<&'a str, ExtensionOutput>; -#[derive(Debug, PartialEq)] +#[derive(Debug, PartialEq, Eq)] pub enum ExtensionOutput { Single(String), Multiple(HashMap), diff --git a/espanso-render/src/renderer/util.rs b/espanso-render/src/renderer/util.rs index 299e164..3152c4a 100644 --- a/espanso-render/src/renderer/util.rs +++ b/espanso-render/src/renderer/util.rs @@ -78,7 +78,7 @@ pub(crate) fn render_variables(body: &str, scope: &Scope) -> Result { ExtensionOutput::Multiple(results) => match var_subname { Some(var_subname) => { let var_subname = var_subname.as_str(); - results.get(var_subname).map_or("", |value| &*value) + results.get(var_subname).map_or("", |value| value) } None => { error!( diff --git a/espanso-ui/src/event.rs b/espanso-ui/src/event.rs index b3eb580..e344059 100644 --- a/espanso-ui/src/event.rs +++ b/espanso-ui/src/event.rs @@ -17,7 +17,7 @@ * along with espanso. If not, see . */ -#[derive(Debug, PartialEq, Clone)] +#[derive(Debug, PartialEq, Clone, Eq)] pub enum UIEvent { TrayIconClick, ContextMenuClick(u32), diff --git a/espanso/src/cli/mod.rs b/espanso/src/cli/mod.rs index 258b5a1..7e3639e 100644 --- a/espanso/src/cli/mod.rs +++ b/espanso/src/cli/mod.rs @@ -67,7 +67,7 @@ impl Default for CliModule { } } -#[derive(Debug, PartialEq)] +#[derive(Debug, PartialEq, Eq)] pub enum LogMode { Read, AppendOnly,