From 75c3d6e1b3bdc242e276c029644001ab8d2f0cee Mon Sep 17 00:00:00 2001 From: veeso Date: Tue, 9 May 2023 15:06:34 +0200 Subject: [PATCH] lint --- src/system/bookmarks_client.rs | 2 +- src/system/environment.rs | 4 ++-- src/utils/path.rs | 20 ++++++++------------ 3 files changed, 11 insertions(+), 15 deletions(-) diff --git a/src/system/bookmarks_client.rs b/src/system/bookmarks_client.rs index 45013ff9..b133bde3 100644 --- a/src/system/bookmarks_client.rs +++ b/src/system/bookmarks_client.rs @@ -730,7 +730,7 @@ mod tests { // Limit is 2 assert_eq!(client.iter_recents().count(), 2); // Check that 192.168.1.1 has been removed - let key: String = client.iter_recents().nth(0).unwrap().to_string(); + let key: String = client.iter_recents().next().unwrap().to_string(); assert!(matches!( client .hosts diff --git a/src/system/environment.rs b/src/system/environment.rs index baf0b33a..f3090a77 100644 --- a/src/system/environment.rs +++ b/src/system/environment.rs @@ -19,7 +19,7 @@ pub fn init_config_dir() -> Result, String> { } if let Some(dir) = CONF_DIR.as_deref() { - init_dir(&dir).map(Option::Some) + init_dir(dir).map(Option::Some) } else { Ok(None) } @@ -39,7 +39,7 @@ pub fn init_cache_dir() -> Result, String> { } if let Some(dir) = CACHE_DIR.as_deref() { - init_dir(&dir).map(Option::Some) + init_dir(dir).map(Option::Some) } else { Ok(None) } diff --git a/src/utils/path.rs b/src/utils/path.rs index cb41c258..e010a1dd 100644 --- a/src/utils/path.rs +++ b/src/utils/path.rs @@ -123,24 +123,20 @@ mod test { #[test] fn should_tell_whether_path_is_child_of() { - assert_eq!( - is_child_of(Path::new("/home/foo/foo.txt"), Path::new("/home"),), - true + assert!( + is_child_of(Path::new("/home/foo/foo.txt"), Path::new("/home"),) ); - assert_eq!( - is_child_of(Path::new("/home/foo/foo.txt"), Path::new("/home/foo/"),), - true + assert!( + is_child_of(Path::new("/home/foo/foo.txt"), Path::new("/home/foo/"),) ); - assert_eq!( + assert!( is_child_of( Path::new("/home/foo/foo.txt"), Path::new("/home/foo/foo.txt"), - ), - true + ) ); - assert_eq!( - is_child_of(Path::new("/home/foo/foo.txt"), Path::new("/tmp"),), - false + assert!( + !is_child_of(Path::new("/home/foo/foo.txt"), Path::new("/tmp"),) ); } }