From 1e92cfef5c537efcc191dd83f4a8c85af4e8d123 Mon Sep 17 00:00:00 2001 From: Federico Terzi Date: Sat, 11 Dec 2021 18:19:56 +0100 Subject: [PATCH] fix(misc): fix new clippy warnings --- espanso-clipboard/src/lib.rs | 9 +-------- espanso-inject/src/lib.rs | 14 +------------- espanso-match/src/rolling/mod.rs | 12 +----------- espanso/src/cli/mod.rs | 15 +-------------- .../engine/dispatch/executor/context_menu.rs | 6 +----- espanso/src/cli/worker/engine/funnel/key_state.rs | 9 +-------- 6 files changed, 6 insertions(+), 59 deletions(-) diff --git a/espanso-clipboard/src/lib.rs b/espanso-clipboard/src/lib.rs index 7416ce4..68dfecf 100644 --- a/espanso-clipboard/src/lib.rs +++ b/espanso-clipboard/src/lib.rs @@ -49,18 +49,11 @@ pub trait Clipboard { } #[allow(dead_code)] +#[derive(Default)] pub struct ClipboardOperationOptions { pub use_xclip_backend: bool, } -impl Default for ClipboardOperationOptions { - fn default() -> Self { - Self { - use_xclip_backend: false, - } - } -} - #[allow(dead_code)] pub struct ClipboardOptions { // Wayland-only diff --git a/espanso-inject/src/lib.rs b/espanso-inject/src/lib.rs index 5536474..ebc086e 100644 --- a/espanso-inject/src/lib.rs +++ b/espanso-inject/src/lib.rs @@ -89,6 +89,7 @@ impl Default for InjectionOptions { } #[allow(dead_code)] +#[derive(Default)] pub struct InjectorCreationOptions { // Only relevant in X11 Linux systems, use the EVDEV backend instead of X11. pub use_evdev: bool, @@ -128,19 +129,6 @@ pub trait KeyboardStateProvider { fn is_key_pressed(&self, code: u32) -> bool; } -#[allow(clippy::derivable_impls)] -impl Default for InjectorCreationOptions { - fn default() -> Self { - Self { - use_evdev: false, - evdev_modifiers: None, - evdev_max_modifier_combination_len: None, - evdev_keyboard_rmlvo: None, - keyboard_state_provider: None, - } - } -} - #[cfg(target_os = "windows")] pub fn get_injector(_options: InjectorCreationOptions) -> Result> { info!("using Win32Injector"); diff --git a/espanso-match/src/rolling/mod.rs b/espanso-match/src/rolling/mod.rs index d51fb57..ec2db0e 100644 --- a/espanso-match/src/rolling/mod.rs +++ b/espanso-match/src/rolling/mod.rs @@ -72,23 +72,13 @@ impl RollingMatch { } } +#[derive(Default)] pub struct StringMatchOptions { pub case_insensitive: bool, pub left_word: bool, pub right_word: bool, } -#[allow(clippy::derivable_impls)] -impl Default for StringMatchOptions { - fn default() -> Self { - Self { - case_insensitive: false, - left_word: false, - right_word: false, - } - } -} - #[cfg(test)] mod tests { use super::*; diff --git a/espanso/src/cli/mod.rs b/espanso/src/cli/mod.rs index f7a3768..258b5a1 100644 --- a/espanso/src/cli/mod.rs +++ b/espanso/src/cli/mod.rs @@ -74,6 +74,7 @@ pub enum LogMode { CleanAndAppend, } +#[derive(Default)] pub struct CliModuleArgs { pub config_store: Option>, pub match_store: Option>, @@ -84,20 +85,6 @@ pub struct CliModuleArgs { pub cli_args: Option>, } -impl Default for CliModuleArgs { - fn default() -> Self { - Self { - config_store: None, - match_store: None, - is_legacy_config: false, - non_fatal_errors: Vec::new(), - paths: None, - paths_overrides: None, - cli_args: None, - } - } -} - pub struct PathsOverrides { pub config: Option, pub runtime: Option, diff --git a/espanso/src/cli/worker/engine/dispatch/executor/context_menu.rs b/espanso/src/cli/worker/engine/dispatch/executor/context_menu.rs index 01b8711..b982964 100644 --- a/espanso/src/cli/worker/engine/dispatch/executor/context_menu.rs +++ b/espanso/src/cli/worker/engine/dispatch/executor/context_menu.rs @@ -58,11 +58,7 @@ fn convert_to_ui_menu_item( espanso_engine::event::ui::MenuItem::Sub(sub) => { espanso_ui::menu::MenuItem::Sub(espanso_ui::menu::SubMenuItem { label: sub.label.clone(), - items: sub - .items - .iter() - .map(|item| convert_to_ui_menu_item(item)) - .collect(), + items: sub.items.iter().map(convert_to_ui_menu_item).collect(), }) } espanso_engine::event::ui::MenuItem::Separator => espanso_ui::menu::MenuItem::Separator, diff --git a/espanso/src/cli/worker/engine/funnel/key_state.rs b/espanso/src/cli/worker/engine/funnel/key_state.rs index f352219..8b50a97 100644 --- a/espanso/src/cli/worker/engine/funnel/key_state.rs +++ b/espanso/src/cli/worker/engine/funnel/key_state.rs @@ -76,18 +76,11 @@ impl KeyStateStore { } } +#[derive(Default)] struct KeyState { keys: HashMap, } -impl Default for KeyState { - fn default() -> Self { - Self { - keys: HashMap::new(), - } - } -} - struct KeyStatus { pressed_at: Option, }