From 16022c78ae333ed3a750bdd26a39ec1e7e8299f6 Mon Sep 17 00:00:00 2001 From: unsecretised Date: Fri, 19 Dec 2025 10:27:52 +0800 Subject: [PATCH 1/2] Fix issues clippy highlighted --- src/app.rs | 6 +----- src/utils.rs | 30 ++++++++++++++---------------- 2 files changed, 15 insertions(+), 21 deletions(-) diff --git a/src/app.rs b/src/app.rs index d9da9ea..e7c7db0 100644 --- a/src/app.rs +++ b/src/app.rs @@ -15,7 +15,6 @@ use iced::{ }, window::{self, Id, Settings}, }; -use std::path::Path; #[cfg(target_os = "macos")] use crate::macos::{focus_this_app, transform_process_to_ui_element}; @@ -146,9 +145,6 @@ pub fn default_settings() -> Settings { } } -#[derive(Debug, Clone)] -pub struct Temp {} - #[derive(Debug, Clone)] pub struct Tile { theme: iced::Theme, @@ -170,7 +166,7 @@ pub struct Tile { impl Tile { /// A base window pub fn new(keybind_id: u32, config: &Config) -> (Self, Task) { - let mut settings = default_settings(); + let settings = default_settings(); #[cfg(target_os = "windows")] { // get normal settings and modify position diff --git a/src/utils.rs b/src/utils.rs index b7cb5bb..f643248 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -5,9 +5,8 @@ use std::{ process::exit, }; -use crate::app::{DEFAULT_WINDOW_HEIGHT, WINDOW_WIDTH}; use global_hotkey::hotkey::Code; -use iced::{futures::io::Window, widget::image::Handle}; +use iced::widget::image::Handle; use icns::IconFamily; use image::RgbaImage; use rayon::iter::{IntoParallelIterator, ParallelIterator}; @@ -300,29 +299,29 @@ pub fn to_key_code(key_str: &str) -> Option { } pub fn get_config_installation_dir() -> String { - let path = if cfg!(target_os = "windows") { + + + if cfg!(target_os = "windows") { std::env::var("LOCALAPPDATA").unwrap() } else { std::env::var("HOME").unwrap() - }; - - return path; + } } pub fn get_config_file_path() -> String { let home = get_config_installation_dir(); - let file_path = if cfg!(target_os = "windows") { + + + if cfg!(target_os = "windows") { home + "\\rustcast\\config.toml" } else { home + "/.config/rustcast/config.toml" - }; - - return file_path; + } } use crate::config::Config; pub fn read_config_file(file_path: &str) -> Result { - let config: Config = match std::fs::read_to_string(&file_path) { + let config: Config = match std::fs::read_to_string(file_path) { Ok(a) => toml::from_str(&a).unwrap(), Err(_) => Config::default(), }; @@ -335,11 +334,10 @@ pub fn create_config_file_if_not_exists( config: &Config, ) -> Result<(), std::io::Error> { // check if file exists - if let Ok(exists) = std::fs::metadata(&file_path) { - if exists.is_file() { + if let Ok(exists) = std::fs::metadata(file_path) + && exists.is_file() { return Ok(()); } - } let path = Path::new(&file_path); if let Some(parent) = path.parent() { @@ -347,7 +345,7 @@ pub fn create_config_file_if_not_exists( } std::fs::write( - &file_path, + file_path, toml::to_string(&config).unwrap_or_else(|x| x.to_string()), ) .unwrap(); @@ -355,7 +353,7 @@ pub fn create_config_file_if_not_exists( Ok(()) } -pub fn open_application(path: &String) { +pub fn open_application(path: &str) { #[cfg(target_os = "windows")] { use std::process::Command; From 188c908df611a09540e25652f0fb75832084ab46 Mon Sep 17 00:00:00 2001 From: unsecretised Date: Fri, 19 Dec 2025 10:28:46 +0800 Subject: [PATCH 2/2] Formatting --- src/utils.rs | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/utils.rs b/src/utils.rs index f643248..7390751 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -299,8 +299,6 @@ pub fn to_key_code(key_str: &str) -> Option { } pub fn get_config_installation_dir() -> String { - - if cfg!(target_os = "windows") { std::env::var("LOCALAPPDATA").unwrap() } else { @@ -310,7 +308,6 @@ pub fn get_config_installation_dir() -> String { pub fn get_config_file_path() -> String { let home = get_config_installation_dir(); - if cfg!(target_os = "windows") { home + "\\rustcast\\config.toml" @@ -335,9 +332,10 @@ pub fn create_config_file_if_not_exists( ) -> Result<(), std::io::Error> { // check if file exists if let Ok(exists) = std::fs::metadata(file_path) - && exists.is_file() { - return Ok(()); - } + && exists.is_file() + { + return Ok(()); + } let path = Path::new(&file_path); if let Some(parent) = path.parent() {