diff options
Diffstat (limited to 'src/commands')
-rw-r--r-- | src/commands/bulk_rename.rs | 4 | ||||
-rw-r--r-- | src/commands/command_line.rs | 3 | ||||
-rw-r--r-- | src/commands/cursor_move.rs | 2 | ||||
-rw-r--r-- | src/commands/file_ops/local_state.rs | 3 | ||||
-rw-r--r-- | src/commands/file_ops/paste_copy.rs | 1 | ||||
-rw-r--r-- | src/commands/file_ops/paste_cut.rs | 1 | ||||
-rw-r--r-- | src/commands/open_file.rs | 4 | ||||
-rw-r--r-- | src/commands/rename_file.rs | 8 | ||||
-rw-r--r-- | src/commands/set_mode.rs | 2 |
9 files changed, 10 insertions, 18 deletions
diff --git a/src/commands/bulk_rename.rs b/src/commands/bulk_rename.rs index e22be06..f1f9549 100644 --- a/src/commands/bulk_rename.rs +++ b/src/commands/bulk_rename.rs @@ -57,7 +57,7 @@ impl BulkRename { let file_name = path.file_name().unwrap(); let file_name_as_bytes = file_name.to_str().unwrap().as_bytes(); file.write(file_name_as_bytes)?; - file.write(&['\n' as u8])?; + file.write(&[b'\n'])?; } } @@ -82,7 +82,7 @@ impl BulkRename { for line in reader.lines() { let line2 = line?; let line = line2.trim(); - if line.len() == 0 { + if line.is_empty() { continue; } let path = path::PathBuf::from(line); diff --git a/src/commands/command_line.rs b/src/commands/command_line.rs index f44c4a5..0714ed2 100644 --- a/src/commands/command_line.rs +++ b/src/commands/command_line.rs @@ -58,7 +58,6 @@ impl std::fmt::Display for CommandLine { impl JoshutoRunnable for CommandLine { fn execute(&self, context: &mut JoshutoContext, backend: &mut TuiBackend) -> JoshutoResult<()> { - let res = self.readline(context, backend); - res + self.readline(context, backend) } } diff --git a/src/commands/cursor_move.rs b/src/commands/cursor_move.rs index 0306d93..ba536bb 100644 --- a/src/commands/cursor_move.rs +++ b/src/commands/cursor_move.rs @@ -13,7 +13,7 @@ pub fn cursor_move(new_index: usize, context: &mut JoshutoContext) { let mut path: Option<PathBuf> = None; if let Some(curr_list) = curr_tab.curr_list_mut() { - if let Some(_) = curr_list.index { + if curr_list.index.is_some() { let dir_len = curr_list.contents.len(); if new_index >= dir_len { new_index = dir_len - 1; diff --git a/src/commands/file_ops/local_state.rs b/src/commands/file_ops/local_state.rs index 2849893..12ffa6c 100644 --- a/src/commands/file_ops/local_state.rs +++ b/src/commands/file_ops/local_state.rs @@ -46,8 +46,7 @@ impl LocalState { } pub fn take_selected_files() -> Option<Vec<path::PathBuf>> { - let paths = SELECTED_FILES.lock().unwrap().take(); - paths + SELECTED_FILES.lock().unwrap().take() } pub fn get_file_operation() -> FileOp { diff --git a/src/commands/file_ops/paste_copy.rs b/src/commands/file_ops/paste_copy.rs index 3a430d1..b1a7368 100644 --- a/src/commands/file_ops/paste_copy.rs +++ b/src/commands/file_ops/paste_copy.rs @@ -5,7 +5,6 @@ use std::thread; use crate::context::JoshutoContext; use crate::io::{IOWorkerThread, Options}; -use crate::util::event::Event; use super::local_state::LocalState; use super::name_resolution::rename_filename_conflict; diff --git a/src/commands/file_ops/paste_cut.rs b/src/commands/file_ops/paste_cut.rs index fb9dc72..2bb9adc 100644 --- a/src/commands/file_ops/paste_cut.rs +++ b/src/commands/file_ops/paste_cut.rs @@ -5,7 +5,6 @@ use std::thread; use crate::context::JoshutoContext; use crate::io::{IOWorkerThread, Options}; -use crate::util::event::Event; use super::local_state::LocalState; use super::name_resolution::rename_filename_conflict; diff --git a/src/commands/open_file.rs b/src/commands/open_file.rs index c871c29..5d1e7de 100644 --- a/src/commands/open_file.rs +++ b/src/commands/open_file.rs @@ -53,7 +53,7 @@ impl OpenFile { LoadChild::load_child(context)?; } else if let Some(paths) = filepaths { let options = Self::get_options(paths[0]); - if options.len() > 0 { + if !options.is_empty() { backend.terminal_drop(); let res = options[0].execute_with(&paths); backend.terminal_restore()?; @@ -97,7 +97,7 @@ impl OpenFileWith { backend: &mut TuiBackend, paths: &[&PathBuf], ) -> std::io::Result<()> { - const PROMPT: &'static str = "open_with "; + const PROMPT: &str = "open_with "; let mimetype_options: Vec<&JoshutoMimetypeEntry> = OpenFile::get_options(&paths[0]); diff --git a/src/commands/rename_file.rs b/src/commands/rename_file.rs index 7ee4272..0bab5e6 100644 --- a/src/commands/rename_file.rs +++ b/src/commands/rename_file.rs @@ -109,9 +109,7 @@ impl JoshutoRunnable for RenameFileAppend { let mut file_name: Option<String> = None; if let Some(curr_list) = context.curr_tab_ref().curr_list_ref() { - file_name = curr_list - .get_curr_ref() - .and_then(|s| Some(s.file_name().to_string())); + file_name = curr_list.get_curr_ref().map(|s| s.file_name().to_string()); } if let Some(file_name) = file_name { @@ -160,9 +158,7 @@ impl JoshutoRunnable for RenameFilePrepend { let mut file_name: Option<String> = None; if let Some(curr_list) = context.curr_tab_ref().curr_list_ref() { - file_name = curr_list - .get_curr_ref() - .and_then(|s| Some(s.file_name().to_string())); + file_name = curr_list.get_curr_ref().map(|s| s.file_name().to_string()); } if let Some(file_name) = file_name { diff --git a/src/commands/set_mode.rs b/src/commands/set_mode.rs index d23c366..b3e6bf5 100644 --- a/src/commands/set_mode.rs +++ b/src/commands/set_mode.rs @@ -52,7 +52,7 @@ impl JoshutoRunnable for SetMode { fn execute(&self, context: &mut JoshutoContext, backend: &mut TuiBackend) -> JoshutoResult<()> { use std::os::unix::fs::PermissionsExt; - const PREFIX: &'static str = "set_mode "; + const PREFIX: &str = "set_mode "; let entry = context.tabs[context.curr_tab_index] .curr_list_ref() |