Skip to content

Commit 9fde49e

Browse files
authored
Merge pull request #37 from unsecretised/windows-support-clippy-fixes
Fix issues clippy highlighted
2 parents ea49759 + 188c908 commit 9fde49e

2 files changed

Lines changed: 14 additions & 22 deletions

File tree

src/app.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ use iced::{
1515
},
1616
window::{self, Id, Settings},
1717
};
18-
use std::path::Path;
1918

2019
#[cfg(target_os = "macos")]
2120
use crate::macos::{focus_this_app, transform_process_to_ui_element};
@@ -146,9 +145,6 @@ pub fn default_settings() -> Settings {
146145
}
147146
}
148147

149-
#[derive(Debug, Clone)]
150-
pub struct Temp {}
151-
152148
#[derive(Debug, Clone)]
153149
pub struct Tile {
154150
theme: iced::Theme,
@@ -170,7 +166,7 @@ pub struct Tile {
170166
impl Tile {
171167
/// A base window
172168
pub fn new(keybind_id: u32, config: &Config) -> (Self, Task<Message>) {
173-
let mut settings = default_settings();
169+
let settings = default_settings();
174170
#[cfg(target_os = "windows")]
175171
{
176172
// get normal settings and modify position

src/utils.rs

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,8 @@ use std::{
55
process::exit,
66
};
77

8-
use crate::app::{DEFAULT_WINDOW_HEIGHT, WINDOW_WIDTH};
98
use global_hotkey::hotkey::Code;
10-
use iced::{futures::io::Window, widget::image::Handle};
9+
use iced::widget::image::Handle;
1110
use icns::IconFamily;
1211
use image::RgbaImage;
1312
use rayon::iter::{IntoParallelIterator, ParallelIterator};
@@ -300,29 +299,26 @@ pub fn to_key_code(key_str: &str) -> Option<Code> {
300299
}
301300

302301
pub fn get_config_installation_dir() -> String {
303-
let path = if cfg!(target_os = "windows") {
302+
if cfg!(target_os = "windows") {
304303
std::env::var("LOCALAPPDATA").unwrap()
305304
} else {
306305
std::env::var("HOME").unwrap()
307-
};
308-
309-
return path;
306+
}
310307
}
311308

312309
pub fn get_config_file_path() -> String {
313310
let home = get_config_installation_dir();
314-
let file_path = if cfg!(target_os = "windows") {
311+
312+
if cfg!(target_os = "windows") {
315313
home + "\\rustcast\\config.toml"
316314
} else {
317315
home + "/.config/rustcast/config.toml"
318-
};
319-
320-
return file_path;
316+
}
321317
}
322318
use crate::config::Config;
323319

324320
pub fn read_config_file(file_path: &str) -> Result<Config, std::io::Error> {
325-
let config: Config = match std::fs::read_to_string(&file_path) {
321+
let config: Config = match std::fs::read_to_string(file_path) {
326322
Ok(a) => toml::from_str(&a).unwrap(),
327323
Err(_) => Config::default(),
328324
};
@@ -335,10 +331,10 @@ pub fn create_config_file_if_not_exists(
335331
config: &Config,
336332
) -> Result<(), std::io::Error> {
337333
// check if file exists
338-
if let Ok(exists) = std::fs::metadata(&file_path) {
339-
if exists.is_file() {
340-
return Ok(());
341-
}
334+
if let Ok(exists) = std::fs::metadata(file_path)
335+
&& exists.is_file()
336+
{
337+
return Ok(());
342338
}
343339

344340
let path = Path::new(&file_path);
@@ -347,15 +343,15 @@ pub fn create_config_file_if_not_exists(
347343
}
348344

349345
std::fs::write(
350-
&file_path,
346+
file_path,
351347
toml::to_string(&config).unwrap_or_else(|x| x.to_string()),
352348
)
353349
.unwrap();
354350

355351
Ok(())
356352
}
357353

358-
pub fn open_application(path: &String) {
354+
pub fn open_application(path: &str) {
359355
#[cfg(target_os = "windows")]
360356
{
361357
use std::process::Command;

0 commit comments

Comments
 (0)