fix(misc): fix clippy warnings (#1342)

* fix(misc): fix clippy warnings

* fix(misc): fix clippy warnings

* fix(misc): fix clippy warnings

* fix(misc): fix clippy warnings

* fix(misc): fix clippy warnings
This commit is contained in:
Federico Terzi 2022-08-25 21:23:55 +02:00 committed by GitHub
parent ee14983f7c
commit 5256e3e79f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
37 changed files with 93 additions and 99 deletions

View File

@ -16,6 +16,7 @@ env:
jobs: jobs:
build: build:
strategy: strategy:
fail-fast: false
matrix: matrix:
os: [windows-latest, macos-latest, ubuntu-latest] os: [windows-latest, macos-latest, ubuntu-latest]

View File

@ -64,7 +64,7 @@ impl ErrorRecord {
} }
} }
#[derive(Debug, PartialEq)] #[derive(Debug, PartialEq, Eq)]
pub enum ErrorLevel { pub enum ErrorLevel {
Error, Error,
Warning, Warning,

View File

@ -386,7 +386,7 @@ impl LegacyConfig {
} }
} }
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Eq)]
pub enum BackendType { pub enum BackendType {
Inject, Inject,
Clipboard, Clipboard,
@ -740,7 +740,7 @@ impl LegacyConfigSet {
} }
// Error handling // Error handling
#[derive(Debug, PartialEq)] #[derive(Debug, PartialEq, Eq)]
#[allow(dead_code)] #[allow(dead_code)]
pub enum ConfigLoadError { pub enum ConfigLoadError {
FileNotFound, FileNotFound,

View File

@ -21,7 +21,7 @@ use serde::{Deserialize, Serialize};
#[allow(non_camel_case_types)] #[allow(non_camel_case_types)]
#[allow(clippy::upper_case_acronyms)] #[allow(clippy::upper_case_acronyms)]
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Eq)]
pub enum KeyModifier { pub enum KeyModifier {
CTRL, CTRL,
SHIFT, SHIFT,

View File

@ -119,7 +119,7 @@ pub struct YAMLMatch {
pub search_terms: Option<Vec<String>>, pub search_terms: Option<Vec<String>>,
} }
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)] #[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Eq)]
pub struct YAMLVariable { pub struct YAMLVariable {
pub name: String, pub name: String,

View File

@ -28,7 +28,7 @@ pub trait MatchStore: Send {
fn loaded_paths(&self) -> Vec<String>; fn loaded_paths(&self) -> Vec<String>;
} }
#[derive(Debug, Clone, PartialEq)] #[derive(Debug, Clone, PartialEq, Eq)]
pub struct MatchSet<'a> { pub struct MatchSet<'a> {
pub matches: Vec<&'a Match>, pub matches: Vec<&'a Match>,
pub global_vars: Vec<&'a Variable>, pub global_vars: Vec<&'a Variable>,

View File

@ -19,7 +19,7 @@
#[cfg(test)] #[cfg(test)]
use enum_as_inner::EnumAsInner; use enum_as_inner::EnumAsInner;
#[derive(Debug, PartialEq)] #[derive(Debug, PartialEq, Eq)]
#[cfg_attr(test, derive(EnumAsInner))] #[cfg_attr(test, derive(EnumAsInner))]
pub enum InputEvent { pub enum InputEvent {
Mouse(MouseEvent), Mouse(MouseEvent),
@ -32,7 +32,7 @@ pub enum InputEvent {
AllModifiersReleased, AllModifiersReleased,
} }
#[derive(Debug, PartialEq)] #[derive(Debug, PartialEq, Eq)]
pub enum MouseButton { pub enum MouseButton {
Left, Left,
Right, Right,
@ -44,25 +44,25 @@ pub enum MouseButton {
Button5, Button5,
} }
#[derive(Debug, PartialEq)] #[derive(Debug, PartialEq, Eq)]
pub struct MouseEvent { pub struct MouseEvent {
pub button: MouseButton, pub button: MouseButton,
pub status: Status, pub status: Status,
} }
#[derive(Debug, PartialEq)] #[derive(Debug, PartialEq, Eq)]
pub enum Status { pub enum Status {
Pressed, Pressed,
Released, Released,
} }
#[derive(Debug, PartialEq)] #[derive(Debug, PartialEq, Eq)]
pub enum Variant { pub enum Variant {
Left, Left,
Right, Right,
} }
#[derive(Debug, PartialEq)] #[derive(Debug, PartialEq, Eq)]
pub struct KeyboardEvent { pub struct KeyboardEvent {
pub key: Key, pub key: Key,
pub value: Option<String>, pub value: Option<String>,
@ -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 // 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 { pub enum Key {
// Modifiers // Modifiers
Alt, Alt,
@ -141,7 +141,7 @@ pub enum Key {
Other(i32), Other(i32),
} }
#[derive(Debug, PartialEq)] #[derive(Debug, PartialEq, Eq)]
pub struct HotKeyEvent { pub struct HotKeyEvent {
pub hotkey_id: i32, pub hotkey_id: i32,
} }

View File

@ -25,7 +25,7 @@ lazy_static! {
static ref RAW_PARSER: Regex = Regex::new(r"^RAW\((\d+)\)$").unwrap(); static ref RAW_PARSER: Regex = Regex::new(r"^RAW\((\d+)\)$").unwrap();
} }
#[derive(Debug, PartialEq, Clone)] #[derive(Debug, PartialEq, Clone, Eq)]
pub enum ShortcutKey { pub enum ShortcutKey {
Alt, Alt,
Control, Control,

View File

@ -32,7 +32,7 @@ static MODIFIERS: &[ShortcutKey; 4] = &[
ShortcutKey::Meta, ShortcutKey::Meta,
]; ];
#[derive(Debug, PartialEq, Clone)] #[derive(Debug, PartialEq, Clone, Eq)]
pub struct HotKey { pub struct HotKey {
pub id: i32, pub id: i32,
pub key: ShortcutKey, pub key: ShortcutKey,

View File

@ -19,13 +19,13 @@
use super::input::Key; use super::input::Key;
#[derive(Debug, Clone, PartialEq)] #[derive(Debug, Clone, PartialEq, Eq)]
pub struct TriggerCompensationEvent { pub struct TriggerCompensationEvent {
pub trigger: String, pub trigger: String,
pub left_separator: Option<String>, pub left_separator: Option<String>,
} }
#[derive(Debug, Clone, PartialEq)] #[derive(Debug, Clone, PartialEq, Eq)]
pub struct CursorHintCompensationEvent { pub struct CursorHintCompensationEvent {
pub cursor_hint_back_count: usize, pub cursor_hint_back_count: usize,
} }
@ -46,7 +46,7 @@ pub struct HtmlInjectRequest {
pub html: String, pub html: String,
} }
#[derive(Debug, PartialEq, Clone)] #[derive(Debug, PartialEq, Clone, Eq)]
pub enum TextInjectMode { pub enum TextInjectMode {
Keys, Keys,
Clipboard, Clipboard,

View File

@ -19,7 +19,7 @@
use std::collections::HashMap; use std::collections::HashMap;
#[derive(Debug, Clone, PartialEq)] #[derive(Debug, Clone, PartialEq, Eq)]
pub struct MatchExecRequestEvent { pub struct MatchExecRequestEvent {
pub trigger: Option<String>, pub trigger: Option<String>,
pub args: HashMap<String, String>, pub args: HashMap<String, String>,

View File

@ -17,19 +17,19 @@
* along with espanso. If not, see <https://www.gnu.org/licenses/>. * along with espanso. If not, see <https://www.gnu.org/licenses/>.
*/ */
#[derive(Debug, PartialEq, Clone)] #[derive(Debug, PartialEq, Clone, Eq)]
pub enum Status { pub enum Status {
Pressed, Pressed,
Released, Released,
} }
#[derive(Debug, PartialEq, Clone)] #[derive(Debug, PartialEq, Clone, Eq)]
pub enum Variant { pub enum Variant {
Left, Left,
Right, Right,
} }
#[derive(Debug, PartialEq, Clone)] #[derive(Debug, PartialEq, Clone, Eq)]
pub struct KeyboardEvent { pub struct KeyboardEvent {
pub key: Key, pub key: Key,
pub value: Option<String>, pub value: Option<String>,
@ -37,7 +37,7 @@ pub struct KeyboardEvent {
pub variant: Option<Variant>, pub variant: Option<Variant>,
} }
#[derive(Debug, Clone, PartialEq)] #[derive(Debug, Clone, PartialEq, Eq)]
pub enum MouseButton { pub enum MouseButton {
Left, Left,
Right, Right,
@ -49,13 +49,13 @@ pub enum MouseButton {
Button5, Button5,
} }
#[derive(Debug, Clone, PartialEq)] #[derive(Debug, Clone, PartialEq, Eq)]
pub struct MouseEvent { pub struct MouseEvent {
pub button: MouseButton, pub button: MouseButton,
pub status: Status, pub status: Status,
} }
#[derive(Debug, Clone, PartialEq)] #[derive(Debug, Clone, PartialEq, Eq)]
pub enum Key { pub enum Key {
// Modifiers // Modifiers
Alt, Alt,
@ -124,12 +124,12 @@ pub enum Key {
Other(i32), Other(i32),
} }
#[derive(Debug, Clone, PartialEq)] #[derive(Debug, Clone, PartialEq, Eq)]
pub struct ContextMenuClickedEvent { pub struct ContextMenuClickedEvent {
pub context_item_id: u32, pub context_item_id: u32,
} }
#[derive(Debug, Clone, PartialEq)] #[derive(Debug, Clone, PartialEq, Eq)]
pub struct HotKeyEvent { pub struct HotKeyEvent {
pub hotkey_id: i32, pub hotkey_id: i32,
} }

View File

@ -19,13 +19,13 @@
use std::collections::HashMap; use std::collections::HashMap;
#[derive(Debug, Clone, PartialEq)] #[derive(Debug, Clone, PartialEq, Eq)]
pub struct MatchesDetectedEvent { pub struct MatchesDetectedEvent {
pub matches: Vec<DetectedMatch>, pub matches: Vec<DetectedMatch>,
pub is_search: bool, pub is_search: bool,
} }
#[derive(Debug, Clone, PartialEq, Default)] #[derive(Debug, Clone, PartialEq, Default, Eq)]
pub struct DetectedMatch { pub struct DetectedMatch {
pub id: i32, pub id: i32,
pub trigger: Option<String>, pub trigger: Option<String>,
@ -34,17 +34,17 @@ pub struct DetectedMatch {
pub args: HashMap<String, String>, pub args: HashMap<String, String>,
} }
#[derive(Debug, Clone, PartialEq)] #[derive(Debug, Clone, PartialEq, Eq)]
pub struct MatchSelectedEvent { pub struct MatchSelectedEvent {
pub chosen: DetectedMatch, pub chosen: DetectedMatch,
} }
#[derive(Debug, Clone, PartialEq)] #[derive(Debug, Clone, PartialEq, Eq)]
pub struct CauseCompensatedMatchEvent { pub struct CauseCompensatedMatchEvent {
pub m: DetectedMatch, pub m: DetectedMatch,
} }
#[derive(Debug, Clone, PartialEq)] #[derive(Debug, Clone, PartialEq, Eq)]
pub struct RenderingRequestedEvent { pub struct RenderingRequestedEvent {
pub match_id: i32, pub match_id: i32,
pub trigger: Option<String>, pub trigger: Option<String>,
@ -54,38 +54,38 @@ pub struct RenderingRequestedEvent {
pub format: TextFormat, pub format: TextFormat,
} }
#[derive(Debug, Clone, PartialEq)] #[derive(Debug, Clone, PartialEq, Eq)]
pub enum TextFormat { pub enum TextFormat {
Plain, Plain,
Markdown, Markdown,
Html, Html,
} }
#[derive(Debug, Clone, PartialEq)] #[derive(Debug, Clone, PartialEq, Eq)]
pub struct ImageRequestedEvent { pub struct ImageRequestedEvent {
pub match_id: i32, pub match_id: i32,
pub image_path: String, pub image_path: String,
} }
#[derive(Debug, Clone, PartialEq)] #[derive(Debug, Clone, PartialEq, Eq)]
pub struct ImageResolvedEvent { pub struct ImageResolvedEvent {
pub image_path: String, pub image_path: String,
} }
#[derive(Debug, Clone, PartialEq)] #[derive(Debug, Clone, PartialEq, Eq)]
pub struct RenderedEvent { pub struct RenderedEvent {
pub match_id: i32, pub match_id: i32,
pub body: String, pub body: String,
pub format: TextFormat, pub format: TextFormat,
} }
#[derive(Debug, Clone, PartialEq)] #[derive(Debug, Clone, PartialEq, Eq)]
pub struct DiscardPreviousEvent { pub struct DiscardPreviousEvent {
// All Events with a source_id smaller than this one will be discarded // All Events with a source_id smaller than this one will be discarded
pub minimum_source_id: u32, pub minimum_source_id: u32,
} }
#[derive(Debug, Clone, PartialEq)] #[derive(Debug, Clone, PartialEq, Eq)]
pub struct DiscardBetweenEvent { pub struct DiscardBetweenEvent {
// All Events with a source_id between start_id (included) and end_id (excluded) // All Events with a source_id between start_id (included) and end_id (excluded)
// will be discarded // will be discarded
@ -93,13 +93,13 @@ pub struct DiscardBetweenEvent {
pub end_id: u32, pub end_id: u32,
} }
#[derive(Debug, Clone, PartialEq)] #[derive(Debug, Clone, PartialEq, Eq)]
pub struct SecureInputEnabledEvent { pub struct SecureInputEnabledEvent {
pub app_name: String, pub app_name: String,
pub app_path: String, pub app_path: String,
} }
#[derive(Debug, Clone, PartialEq)] #[derive(Debug, Clone, PartialEq, Eq)]
pub struct UndoEvent { pub struct UndoEvent {
pub match_id: i32, pub match_id: i32,
pub trigger: String, pub trigger: String,

View File

@ -29,7 +29,7 @@ pub enum MenuItem {
Separator, Separator,
} }
#[derive(Debug, Clone, PartialEq)] #[derive(Debug, Clone, PartialEq, Eq)]
pub struct SimpleMenuItem { pub struct SimpleMenuItem {
pub id: u32, pub id: u32,
pub label: String, pub label: String,
@ -41,19 +41,19 @@ pub struct SubMenuItem {
pub items: Vec<MenuItem>, pub items: Vec<MenuItem>,
} }
#[derive(Debug, Clone, PartialEq)] #[derive(Debug, Clone, PartialEq, Eq)]
pub struct IconStatusChangeEvent { pub struct IconStatusChangeEvent {
pub status: IconStatus, pub status: IconStatus,
} }
#[derive(Debug, Clone, PartialEq)] #[derive(Debug, Clone, PartialEq, Eq)]
pub enum IconStatus { pub enum IconStatus {
Enabled, Enabled,
Disabled, Disabled,
SecureInputDisabled, SecureInputDisabled,
} }
#[derive(Debug, Clone, PartialEq)] #[derive(Debug, Clone, PartialEq, Eq)]
pub struct ShowTextEvent { pub struct ShowTextEvent {
pub title: String, pub title: String,
pub text: String, pub text: String,

View File

@ -44,7 +44,7 @@ pub enum MatcherEvent {
VirtualSeparator, VirtualSeparator,
} }
#[derive(Debug, Clone, PartialEq)] #[derive(Debug, Clone, PartialEq, Eq)]
pub struct MatchResult { pub struct MatchResult {
pub id: i32, pub id: i32,
pub trigger: String, pub trigger: String,
@ -104,7 +104,7 @@ impl<'a, State> Middleware for MatcherMiddleware<'a, State> {
if is_event_of_interest(&event.etype) { if is_event_of_interest(&event.etype) {
let mut matcher_states = self.matcher_states.borrow_mut(); let mut matcher_states = self.matcher_states.borrow_mut();
let prev_states = if !matcher_states.is_empty() { let prev_states = if !matcher_states.is_empty() {
matcher_states.get(matcher_states.len() - 1) matcher_states.back()
} else { } else {
None None
}; };

View File

@ -20,7 +20,7 @@ pub const KeyPress: c_int = 2;
#[allow(non_upper_case_globals)] #[allow(non_upper_case_globals)]
pub const KeyRelease: c_int = 3; pub const KeyRelease: c_int = 3;
#[derive(Debug, Clone, Copy, PartialEq)] #[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[repr(C)] #[repr(C)]
pub struct XKeyEvent { pub struct XKeyEvent {
pub type_: c_int, pub type_: c_int,
@ -40,7 +40,7 @@ pub struct XKeyEvent {
pub same_screen: Bool, pub same_screen: Bool,
} }
#[derive(Debug, Clone, Copy, PartialEq)] #[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[repr(C)] #[repr(C)]
pub struct XModifierKeymap { pub struct XModifierKeymap {
pub max_keypermod: c_int, pub max_keypermod: c_int,

View File

@ -17,13 +17,13 @@
* along with espanso. If not, see <https://www.gnu.org/licenses/>. * along with espanso. If not, see <https://www.gnu.org/licenses/>.
*/ */
#[derive(Debug, Clone, PartialEq)] #[derive(Debug, Clone, PartialEq, Eq)]
pub enum Event { pub enum Event {
Key { key: Key, chars: Option<String> }, Key { key: Key, chars: Option<String> },
VirtualSeparator, VirtualSeparator,
} }
#[derive(Debug, Clone, PartialEq)] #[derive(Debug, Clone, PartialEq, Eq)]
pub enum Key { pub enum Key {
// Modifiers // Modifiers
Alt, Alt,

View File

@ -26,7 +26,7 @@ pub mod regex;
pub mod rolling; pub mod rolling;
mod util; mod util;
#[derive(Debug, Clone, PartialEq)] #[derive(Debug, Clone, PartialEq, Eq)]
pub struct MatchResult<Id> { pub struct MatchResult<Id> {
pub id: Id, pub id: Id,
pub trigger: String, pub trigger: String,

View File

@ -185,7 +185,7 @@ impl<Id: Clone> RollingMatcher<Id> {
// in the state. // in the state.
if !has_previous_state { if !has_previous_state {
if let Some(MatcherTreeRef::Node(node)) = node.word_separators.as_ref() { if let Some(MatcherTreeRef::Node(node)) = node.word_separators.as_ref() {
refs.extend(self.find_refs(&*node, event, true)); refs.extend(self.find_refs(node, event, true));
} }
} }

View File

@ -23,7 +23,7 @@ pub mod matcher;
mod tree; mod tree;
mod util; mod util;
#[derive(Debug, Clone, PartialEq)] #[derive(Debug, Clone, PartialEq, Eq)]
pub enum RollingItem { pub enum RollingItem {
WordSeparator, WordSeparator,
Key(Key), Key(Key),
@ -31,7 +31,7 @@ pub enum RollingItem {
CharInsensitive(String), CharInsensitive(String),
} }
#[derive(Debug, PartialEq)] #[derive(Debug, PartialEq, Eq)]
pub struct RollingMatch<Id> { pub struct RollingMatch<Id> {
pub id: Id, pub id: Id,
pub items: Vec<RollingItem>, pub items: Vec<RollingItem>,

View File

@ -90,7 +90,7 @@ fn build_native() {
) )
.args(&[ .args(&[
"/k", "/k",
&vcvars_path.to_string_lossy().to_string(), &vcvars_path.to_string_lossy(),
"&", "&",
"nmake", "nmake",
"/f", "/f",
@ -320,7 +320,7 @@ fn convert_fat_libraries_to_arm(lib_dir: &Path) {
// Make sure it's a fat library // Make sure it's a fat library
let lipo_output = std::process::Command::new("lipo") let lipo_output = std::process::Command::new("lipo")
.args(&["-detailed_info", &path.to_string_lossy().to_string()]) .args(&["-detailed_info", &path.to_string_lossy()])
.output() .output()
.expect("unable to check if library is fat"); .expect("unable to check if library is fat");
let lipo_output = String::from_utf8_lossy(&lipo_output.stdout); let lipo_output = String::from_utf8_lossy(&lipo_output.stdout);
@ -339,9 +339,9 @@ fn convert_fat_libraries_to_arm(lib_dir: &Path) {
.args(&[ .args(&[
"-thin", "-thin",
"arm64", "arm64",
&path.to_string_lossy().to_string(), &path.to_string_lossy(),
"-output", "-output",
&path.to_string_lossy().to_string(), &path.to_string_lossy(),
]) ])
.output() .output()
.expect("unable to extract arm64 slice from library"); .expect("unable to extract arm64 slice from library");

View File

@ -25,7 +25,7 @@ lazy_static! {
static ref FIELD_REGEX: Regex = Regex::new(r"\{\{(.*?)\}\}|\[\[(.*?)\]\]").unwrap(); static ref FIELD_REGEX: Regex = Regex::new(r"\{\{(.*?)\}\}|\[\[(.*?)\]\]").unwrap();
} }
#[derive(Debug, Clone, PartialEq)] #[derive(Debug, Clone, PartialEq, Eq)]
pub enum Token { pub enum Token {
Text(String), // Text Text(String), // Text
Field(String), // id: String Field(String), // id: String

View File

@ -21,11 +21,10 @@ use std::collections::HashSet;
use crate::sys::search::types::SearchItem; use crate::sys::search::types::SearchItem;
pub fn get_algorithm( type FilterCallback = dyn Fn(&str, &[SearchItem]) -> Vec<usize>;
name: &str,
use_command_filter: bool, pub fn get_algorithm(name: &str, use_command_filter: bool) -> Box<FilterCallback> {
) -> Box<dyn Fn(&str, &[SearchItem]) -> Vec<usize>> { let search_algorithm: Box<FilterCallback> = match name {
let search_algorithm: Box<dyn Fn(&str, &[SearchItem]) -> Vec<usize>> = match name {
"exact" => Box::new(exact_match), "exact" => Box::new(exact_match),
"iexact" => Box::new(case_insensitive_exact_match), "iexact" => Box::new(case_insensitive_exact_match),
"ikey" => Box::new(case_insensitive_keyword), "ikey" => Box::new(case_insensitive_keyword),
@ -100,9 +99,7 @@ fn case_insensitive_keyword(query: &str, items: &[SearchItem]) -> Vec<usize> {
.collect() .collect()
} }
fn command_filter( fn command_filter(search_algorithm: Box<FilterCallback>) -> Box<FilterCallback> {
search_algorithm: Box<dyn Fn(&str, &[SearchItem]) -> Vec<usize>>,
) -> Box<dyn Fn(&str, &[SearchItem]) -> Vec<usize>> {
Box::new(move |query, items| { Box::new(move |query, items| {
let (valid_ids, trimmed_query) = if query.starts_with('>') { let (valid_ids, trimmed_query) = if query.starts_with('>') {
( (

View File

@ -147,16 +147,15 @@ mod interop {
} }
} }
type SearchAlgorithmCallback = dyn Fn(&str, &[types::SearchItem]) -> Vec<usize>;
struct SearchData { struct SearchData {
owned_search: interop::OwnedSearch, owned_search: interop::OwnedSearch,
items: Vec<types::SearchItem>, items: Vec<types::SearchItem>,
algorithm: Box<dyn Fn(&str, &[types::SearchItem]) -> Vec<usize>>, algorithm: Box<SearchAlgorithmCallback>,
} }
pub fn show( pub fn show(search: types::Search, algorithm: Box<SearchAlgorithmCallback>) -> Option<String> {
search: types::Search,
algorithm: Box<dyn Fn(&str, &[types::SearchItem]) -> Vec<usize>>,
) -> Option<String> {
use super::interop::*; use super::interop::*;
let owned_search: interop::OwnedSearch = (&search).into(); let owned_search: interop::OwnedSearch = (&search).into();

View File

@ -44,7 +44,9 @@ pub enum ErrorLevel {
Warning, Warning,
} }
type OpenFileCallback = dyn Fn(&Path) + Send;
pub struct TroubleshootingHandlers { pub struct TroubleshootingHandlers {
pub dont_show_again_changed: Option<Box<dyn Fn(bool) + Send>>, pub dont_show_again_changed: Option<Box<dyn Fn(bool) + Send>>,
pub open_file: Option<Box<dyn Fn(&Path) + Send>>, pub open_file: Option<Box<OpenFileCallback>>,
} }

View File

@ -30,7 +30,7 @@ mod util;
pub const PACKAGE_SOURCE_FILE: &str = "_pkgsource.yml"; pub const PACKAGE_SOURCE_FILE: &str = "_pkgsource.yml";
#[derive(Debug, PartialEq)] #[derive(Debug, PartialEq, Eq)]
pub struct ArchivedPackage { pub struct ArchivedPackage {
// Metadata // Metadata
pub manifest: Manifest, pub manifest: Manifest,
@ -39,12 +39,12 @@ pub struct ArchivedPackage {
pub source: PackageSource, pub source: PackageSource,
} }
#[derive(Debug, PartialEq)] #[derive(Debug, PartialEq, Eq)]
pub struct LegacyPackage { pub struct LegacyPackage {
pub name: String, pub name: String,
} }
#[derive(Debug, PartialEq)] #[derive(Debug, PartialEq, Eq)]
pub enum StoredPackage { pub enum StoredPackage {
Legacy(LegacyPackage), Legacy(LegacyPackage),
Modern(ArchivedPackage), Modern(ArchivedPackage),
@ -67,7 +67,7 @@ pub struct SaveOptions {
pub overwrite_existing: bool, pub overwrite_existing: bool,
} }
#[derive(Debug, Serialize, Deserialize, PartialEq)] #[derive(Debug, Serialize, Deserialize, PartialEq, Eq)]
#[serde(rename_all = "snake_case")] #[serde(rename_all = "snake_case")]
pub enum PackageSource { pub enum PackageSource {
Hub, Hub,

View File

@ -22,7 +22,7 @@ use std::path::Path;
use anyhow::{Context, Result}; use anyhow::{Context, Result};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
#[derive(Debug, PartialEq, Serialize, Deserialize)] #[derive(Debug, PartialEq, Serialize, Deserialize, Eq)]
pub struct Manifest { pub struct Manifest {
pub name: String, pub name: String,
pub title: String, pub title: String,

View File

@ -23,7 +23,7 @@ use anyhow::{anyhow, bail, Context, Result};
use crate::manifest::Manifest; use crate::manifest::Manifest;
#[derive(Debug, PartialEq)] #[derive(Debug, PartialEq, Eq)]
pub struct ResolvedPackage { pub struct ResolvedPackage {
pub manifest: Manifest, pub manifest: Manifest,
pub base_dir: PathBuf, pub base_dir: PathBuf,

View File

@ -82,7 +82,7 @@ fn extract_zip(data: Vec<u8>, dest_dir: &Path) -> Result<()> {
None => continue, None => continue,
}; };
if (&*file.name()).ends_with('/') { if file.name().ends_with('/') {
std::fs::create_dir_all(&outpath)?; std::fs::create_dir_all(&outpath)?;
} else { } else {
if let Some(p) = outpath.parent() { if let Some(p) = outpath.parent() {

View File

@ -28,7 +28,7 @@ lazy_static! {
.unwrap(); .unwrap();
} }
#[derive(Debug, PartialEq)] #[derive(Debug, PartialEq, Eq)]
pub struct GitHubParts { pub struct GitHubParts {
author: String, author: String,
name: String, name: String,

View File

@ -28,7 +28,7 @@ lazy_static! {
.unwrap(); .unwrap();
} }
#[derive(Debug, PartialEq)] #[derive(Debug, PartialEq, Eq)]
pub struct GitLabParts { pub struct GitLabParts {
author: String, author: String,
name: String, name: String,

View File

@ -66,16 +66,13 @@ impl Extension for ScriptExtension {
// Also replace %CONFIG% and %PACKAGES% path. See issue #380 // Also replace %CONFIG% and %PACKAGES% path. See issue #380
args.iter_mut().for_each(|arg| { args.iter_mut().for_each(|arg| {
if arg.contains("%HOME%") { 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%") { 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%") { if arg.contains("%PACKAGES%") {
*arg = arg.replace( *arg = arg.replace("%PACKAGES%", &self.packages_path.to_string_lossy());
"%PACKAGES%",
&self.packages_path.to_string_lossy().to_string(),
);
} }
// On Windows, correct paths separators // On Windows, correct paths separators

View File

@ -48,7 +48,7 @@ pub struct Context<'a> {
pub templates: Vec<&'a Template>, pub templates: Vec<&'a Template>,
} }
#[derive(Debug, Clone, PartialEq)] #[derive(Debug, Clone, PartialEq, Eq)]
pub struct RenderOptions { pub struct RenderOptions {
pub casing_style: CasingStyle, pub casing_style: CasingStyle,
} }
@ -61,7 +61,7 @@ impl Default for RenderOptions {
} }
} }
#[derive(Debug, Clone, PartialEq)] #[derive(Debug, Clone, PartialEq, Eq)]
pub enum CasingStyle { pub enum CasingStyle {
None, None,
Capitalize, Capitalize,
@ -123,7 +123,7 @@ pub trait Extension {
pub type Scope<'a> = HashMap<&'a str, ExtensionOutput>; pub type Scope<'a> = HashMap<&'a str, ExtensionOutput>;
#[derive(Debug, PartialEq)] #[derive(Debug, PartialEq, Eq)]
pub enum ExtensionOutput { pub enum ExtensionOutput {
Single(String), Single(String),
Multiple(HashMap<String, String>), Multiple(HashMap<String, String>),

View File

@ -78,7 +78,7 @@ pub(crate) fn render_variables(body: &str, scope: &Scope) -> Result<String> {
ExtensionOutput::Multiple(results) => match var_subname { ExtensionOutput::Multiple(results) => match var_subname {
Some(var_subname) => { Some(var_subname) => {
let var_subname = var_subname.as_str(); let var_subname = var_subname.as_str();
results.get(var_subname).map_or("", |value| &*value) results.get(var_subname).map_or("", |value| value)
} }
None => { None => {
error!( error!(

View File

@ -17,7 +17,7 @@
* along with espanso. If not, see <https://www.gnu.org/licenses/>. * along with espanso. If not, see <https://www.gnu.org/licenses/>.
*/ */
#[derive(Debug, PartialEq, Clone)] #[derive(Debug, PartialEq, Clone, Eq)]
pub enum UIEvent { pub enum UIEvent {
TrayIconClick, TrayIconClick,
ContextMenuClick(u32), ContextMenuClick(u32),

View File

@ -67,7 +67,7 @@ impl Default for CliModule {
} }
} }
#[derive(Debug, PartialEq)] #[derive(Debug, PartialEq, Eq)]
pub enum LogMode { pub enum LogMode {
Read, Read,
AppendOnly, AppendOnly,

View File

@ -42,10 +42,8 @@ pub fn register() -> Result<()> {
info_println!("creating service file in {:?}", service_file); info_println!("creating service file in {:?}", service_file);
let espanso_path = get_binary_path().expect("unable to get espanso executable path"); let espanso_path = get_binary_path().expect("unable to get espanso executable path");
let service_content = String::from(LINUX_SERVICE_CONTENT).replace( let service_content = String::from(LINUX_SERVICE_CONTENT)
"{{{espanso_path}}}", .replace("{{{espanso_path}}}", &espanso_path.to_string_lossy());
&espanso_path.to_string_lossy().to_string(),
);
std::fs::write(service_file, service_content)?; std::fs::write(service_file, service_content)?;