From 64f7e0f7eff7b5f61162a53d9e1409a873b2f0bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Altu=C4=9F=20Bakan?= Date: Sat, 7 Oct 2023 13:10:53 +0200 Subject: [PATCH] Update clippy improvements --- src/config.rs | 10 +++++----- src/window.rs | 7 ++----- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/src/config.rs b/src/config.rs index 72b0145..92e7038 100644 --- a/src/config.rs +++ b/src/config.rs @@ -108,7 +108,7 @@ mod tests { #[test] fn parses_full_config() { let config = Config::new( - vec!["/", "-i", "0.0.0.0", "-p", "1234", "-d", "/", "-s", "-r"] + ["/", "-i", "0.0.0.0", "-p", "1234", "-d", "/", "-s", "-r"] .iter() .map(|s| s.to_string()), ) @@ -124,7 +124,7 @@ mod tests { #[test] fn parses_some_config() { let config = Config::new( - vec!["/", "-i", "0.0.0.0", "-d", "/"] + ["/", "-i", "0.0.0.0", "-d", "/"] .iter() .map(|s| s.to_string()), ) @@ -138,7 +138,7 @@ mod tests { #[test] fn returns_error_on_invalid_ip() { assert!(Config::new( - vec!["/", "-i", "1234.5678.9012.3456"] + ["/", "-i", "1234.5678.9012.3456"] .iter() .map(|s| s.to_string()), ) @@ -147,13 +147,13 @@ mod tests { #[test] fn returns_error_on_invalid_port() { - assert!(Config::new(vec!["/", "-p", "1234567"].iter().map(|s| s.to_string()),).is_err()); + assert!(Config::new(["/", "-p", "1234567"].iter().map(|s| s.to_string()),).is_err()); } #[test] fn returns_error_on_invalid_directory() { assert!(Config::new( - vec!["/", "-d", "/this/does/not/exist"] + ["/", "-d", "/this/does/not/exist"] .iter() .map(|s| s.to_string()), ) diff --git a/src/window.rs b/src/window.rs index 2a40ade..88efe73 100644 --- a/src/window.rs +++ b/src/window.rs @@ -120,7 +120,6 @@ mod tests { use std::{ fs::{self, OpenOptions}, io::{Seek, Write}, - path::Path, }; const DIR_NAME: &str = "tmp"; @@ -190,10 +189,8 @@ mod tests { fn initialize(file_name: &str) -> File { let file_name = DIR_NAME.to_string() + "/" + file_name; - if !Path::new(DIR_NAME).is_dir() { - if fs::create_dir(DIR_NAME).is_err() { - } - } + + let _ = fs::create_dir_all(DIR_NAME); if File::open(&file_name).is_ok() { fs::remove_file(&file_name).unwrap();