From 8b04fec104cd20b86ff98f4da225bb866a407f8c Mon Sep 17 00:00:00 2001 From: Caleb Bassi Date: Fri, 15 Feb 2019 19:13:42 -0800 Subject: Fix most clippy lints --- src/commands/mod.rs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'src/commands/mod.rs') diff --git a/src/commands/mod.rs b/src/commands/mod.rs index 954dbdc..e7b4df3 100644 --- a/src/commands/mod.rs +++ b/src/commands/mod.rs @@ -76,7 +76,7 @@ pub fn from_args(command: &str, args: Option<&Vec>) -> Option { - for exp_str in exp_strs { + if let Some(exp_str) = exp_strs.into_iter().next() { let path = PathBuf::from(exp_str); return Some(Box::new(self::ChangeDirectory::new(path))); } @@ -86,13 +86,13 @@ pub fn from_args(command: &str, args: Option<&Vec>) -> Option Some(Box::new(self::CloseTab::new())), "copy_files" => Some(Box::new(self::CopyFiles::new())), "cursor_move" => { if let Some(args) = args { - if args.len() > 0 { + if !args.is_empty() { match args[0].parse::() { Ok(s) => { return Some(Box::new(self::CursorMove::new(s))); @@ -103,7 +103,7 @@ pub fn from_args(command: &str, args: Option<&Vec>) -> Option Some(Box::new(self::CursorMoveHome::new())), "cursor_move_end" => Some(Box::new(self::CursorMoveEnd::new())), @@ -150,7 +150,7 @@ pub fn from_args(command: &str, args: Option<&Vec>) -> Option { let method: RenameFileMethod; if let Some(args) = args { - if args.len() > 0 { + if !args.is_empty() { method = match args[0].as_str() { "prepend" => self::RenameFileMethod::Prepend, "overwrite" => self::RenameFileMethod::Overwrite, @@ -198,7 +198,7 @@ pub fn from_args(command: &str, args: Option<&Vec>) -> Option Some(Box::new(self::SetMode::new())), "tab_switch" => { if let Some(args) = args { - if args.len() > 0 { + if !args.is_empty() { match args[0].parse::() { Ok(s) => { return Some(Box::new(self::TabSwitch::new(s))); @@ -209,7 +209,7 @@ pub fn from_args(command: &str, args: Option<&Vec>) -> Option Some(Box::new(self::ToggleHiddenFiles::new())), _ => None, @@ -227,7 +227,7 @@ pub fn collect_selected_paths(dirlist: &structs::JoshutoDirList) -> Option 0 { + if !selected.is_empty() { Some(selected) } else { Some(vec![dirlist.contents[dirlist.index as usize].path.clone()]) @@ -235,7 +235,7 @@ pub fn collect_selected_paths(dirlist: &structs::JoshutoDirList) -> Option Vec<&str> { +pub fn split_shell_style(line: &str) -> Vec<&str> { let mut args: Vec<&str> = Vec::new(); let mut char_ind = line.char_indices(); -- cgit v1.2.3