diff options
author | sushi-shi <47691267+sushi-shi@users.noreply.github.com> | 2022-02-25 03:56:32 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-02-24 19:56:32 -0500 |
commit | 5451fd9865f2a75d623992a072eb639ea20e688f (patch) | |
tree | fca079a571f8fe01dc72c9a05daf6efcea18e091 /src/commands | |
parent | 55b401cfa35ee3ce09d2deba94f0d490ad666e9b (diff) |
Fix clippy warnings (#144)
Diffstat (limited to 'src/commands')
-rw-r--r-- | src/commands/bulk_rename.rs | 4 | ||||
-rw-r--r-- | src/commands/change_directory.rs | 6 | ||||
-rw-r--r-- | src/commands/command_line.rs | 2 | ||||
-rw-r--r-- | src/commands/file_ops.rs | 16 | ||||
-rw-r--r-- | src/commands/help.rs | 22 | ||||
-rw-r--r-- | src/commands/line_nums.rs | 5 | ||||
-rw-r--r-- | src/commands/new_directory.rs | 2 | ||||
-rw-r--r-- | src/commands/numbered_command.rs | 2 | ||||
-rw-r--r-- | src/commands/open_file.rs | 9 | ||||
-rw-r--r-- | src/commands/parent_cursor_move.rs | 6 | ||||
-rw-r--r-- | src/commands/preview_cursor_move.rs | 6 | ||||
-rw-r--r-- | src/commands/quit.rs | 6 | ||||
-rw-r--r-- | src/commands/reload.rs | 2 | ||||
-rw-r--r-- | src/commands/rename_file.rs | 10 | ||||
-rw-r--r-- | src/commands/search.rs | 4 | ||||
-rw-r--r-- | src/commands/search_fzf.rs | 15 | ||||
-rw-r--r-- | src/commands/search_glob.rs | 2 | ||||
-rw-r--r-- | src/commands/selection.rs | 6 | ||||
-rw-r--r-- | src/commands/set_mode.rs | 2 | ||||
-rw-r--r-- | src/commands/show_hidden.rs | 2 | ||||
-rw-r--r-- | src/commands/show_workers.rs | 3 | ||||
-rw-r--r-- | src/commands/sort.rs | 6 | ||||
-rw-r--r-- | src/commands/sub_process.rs | 2 | ||||
-rw-r--r-- | src/commands/subdir_fzf.rs | 22 | ||||
-rw-r--r-- | src/commands/tab_ops.rs | 6 | ||||
-rw-r--r-- | src/commands/touch_file.rs | 7 |
26 files changed, 83 insertions, 92 deletions
diff --git a/src/commands/bulk_rename.rs b/src/commands/bulk_rename.rs index f79bbf2..43facee 100644 --- a/src/commands/bulk_rename.rs +++ b/src/commands/bulk_rename.rs @@ -15,7 +15,7 @@ use super::reload; const ENV_TMP_DIR: &str = "TMP_DIR"; const ENV_EDITOR: &str = "EDITOR"; -pub fn _bulk_rename(context: &mut AppContext) -> JoshutoResult<()> { +pub fn _bulk_rename(context: &mut AppContext) -> JoshutoResult { let tmp_directory = env::var(ENV_TMP_DIR).unwrap_or_else(|_| "/tmp".to_string()); const PREFIX: &str = "joshuto-"; @@ -120,7 +120,7 @@ pub fn _bulk_rename(context: &mut AppContext) -> JoshutoResult<()> { Ok(()) } -pub fn bulk_rename(context: &mut AppContext, backend: &mut TuiBackend) -> JoshutoResult<()> { +pub fn bulk_rename(context: &mut AppContext, backend: &mut TuiBackend) -> JoshutoResult { context.remove_external_preview(); backend.terminal_drop(); let res = _bulk_rename(context); diff --git a/src/commands/change_directory.rs b/src/commands/change_directory.rs index dc1003f..ad6db26 100644 --- a/src/commands/change_directory.rs +++ b/src/commands/change_directory.rs @@ -12,7 +12,7 @@ pub fn cd(path: &path::Path, context: &mut AppContext) -> std::io::Result<()> { Ok(()) } -pub fn change_directory(context: &mut AppContext, path: &path::Path) -> JoshutoResult<()> { +pub fn change_directory(context: &mut AppContext, path: &path::Path) -> JoshutoResult { let new_cwd = if path.is_absolute() { path.canonicalize()? } else { @@ -33,7 +33,7 @@ pub fn change_directory(context: &mut AppContext, path: &path::Path) -> JoshutoR } // ParentDirectory command -pub fn parent_directory(context: &mut AppContext) -> JoshutoResult<()> { +pub fn parent_directory(context: &mut AppContext) -> JoshutoResult { if let Some(parent) = context .tab_context_ref() .curr_tab_ref() @@ -52,7 +52,7 @@ pub fn parent_directory(context: &mut AppContext) -> JoshutoResult<()> { } // PreviousDirectory command -pub fn previous_directory(context: &mut AppContext) -> JoshutoResult<()> { +pub fn previous_directory(context: &mut AppContext) -> JoshutoResult { if let Some(path) = context.tab_context_ref().curr_tab_ref().previous_dir() { let path = path.to_path_buf(); std::env::set_current_dir(&path)?; diff --git a/src/commands/command_line.rs b/src/commands/command_line.rs index 5848b6d..887ea32 100644 --- a/src/commands/command_line.rs +++ b/src/commands/command_line.rs @@ -13,7 +13,7 @@ pub fn read_and_execute( keymap_t: &AppKeyMapping, prefix: &str, suffix: &str, -) -> JoshutoResult<()> { +) -> JoshutoResult { context.flush_event(); let user_input: Option<String> = TuiTextField::default() .prompt(":") diff --git a/src/commands/file_ops.rs b/src/commands/file_ops.rs index dead1ac..7d83209 100644 --- a/src/commands/file_ops.rs +++ b/src/commands/file_ops.rs @@ -7,7 +7,7 @@ use crate::io::FileOp; use crate::io::{IoWorkerOptions, IoWorkerThread}; -pub fn cut(context: &mut AppContext) -> JoshutoResult<()> { +pub fn cut(context: &mut AppContext) -> JoshutoResult { if let Some(list) = context.tab_context_ref().curr_tab_ref().curr_list_ref() { let selected = list.get_selected_paths(); @@ -20,7 +20,7 @@ pub fn cut(context: &mut AppContext) -> JoshutoResult<()> { Ok(()) } -pub fn copy(context: &mut AppContext) -> JoshutoResult<()> { +pub fn copy(context: &mut AppContext) -> JoshutoResult { if let Some(list) = context.tab_context_ref().curr_tab_ref().curr_list_ref() { let selected = list.get_selected_paths(); @@ -33,7 +33,7 @@ pub fn copy(context: &mut AppContext) -> JoshutoResult<()> { Ok(()) } -pub fn paste(context: &mut AppContext, options: IoWorkerOptions) -> JoshutoResult<()> { +pub fn paste(context: &mut AppContext, options: IoWorkerOptions) -> JoshutoResult { match context.take_local_state() { Some(state) if !state.paths.is_empty() => { let dest = context.tab_context_ref().curr_tab_ref().cwd().to_path_buf(); @@ -48,7 +48,7 @@ pub fn paste(context: &mut AppContext, options: IoWorkerOptions) -> JoshutoResul } } -pub fn copy_filename(context: &mut AppContext) -> JoshutoResult<()> { +pub fn copy_filename(context: &mut AppContext) -> JoshutoResult { let entry_file_name = context .tab_context_ref() .curr_tab_ref() @@ -62,7 +62,7 @@ pub fn copy_filename(context: &mut AppContext) -> JoshutoResult<()> { Ok(()) } -pub fn copy_filename_without_extension(context: &mut AppContext) -> JoshutoResult<()> { +pub fn copy_filename_without_extension(context: &mut AppContext) -> JoshutoResult { let entry_file_name = context .tab_context_ref() .curr_tab_ref() @@ -79,7 +79,7 @@ pub fn copy_filename_without_extension(context: &mut AppContext) -> JoshutoResul Ok(()) } -pub fn copy_filepath(context: &mut AppContext) -> JoshutoResult<()> { +pub fn copy_filepath(context: &mut AppContext) -> JoshutoResult { let entry_file_path = context .tab_context_ref() .curr_tab_ref() @@ -94,7 +94,7 @@ pub fn copy_filepath(context: &mut AppContext) -> JoshutoResult<()> { Ok(()) } -pub fn copy_dirpath(context: &mut AppContext) -> JoshutoResult<()> { +pub fn copy_dirpath(context: &mut AppContext) -> JoshutoResult { let opt_entry = context .tab_context_ref() .curr_tab_ref() @@ -109,7 +109,7 @@ pub fn copy_dirpath(context: &mut AppContext) -> JoshutoResult<()> { Ok(()) } -fn copy_string_to_buffer(string: String) -> JoshutoResult<()> { +fn copy_string_to_buffer(string: String) -> JoshutoResult { let clipboards = [ ( "wl-copy", diff --git a/src/commands/help.rs b/src/commands/help.rs index 3c073bb..4f63e4e 100644 --- a/src/commands/help.rs +++ b/src/commands/help.rs @@ -1,3 +1,5 @@ +use std::cmp::Ordering; + use termion::event::{Event, Key}; use crate::config::AppKeyMapping; @@ -14,7 +16,7 @@ pub fn help_loop( context: &mut AppContext, backend: &mut TuiBackend, keymap_t: &AppKeyMapping, -) -> JoshutoResult<()> { +) -> JoshutoResult { context.flush_event(); let mut offset = 0; @@ -84,13 +86,17 @@ pub fn help_loop( // offset is a u8, so if we make it negative program will fail. // This function prevents this error fn move_offset(offset: &mut u8, moving_amount: i8) { - if moving_amount > 0 { - *offset += moving_amount as u8; - } else if moving_amount < 0 { - if *offset > -moving_amount as u8 { - *offset -= -moving_amount as u8; - } else { - *offset = 0; + match moving_amount.cmp(&0) { + Ordering::Greater => { + *offset += moving_amount as u8; + } + Ordering::Less => { + if *offset > -moving_amount as u8 { + *offset -= -moving_amount as u8; + } else { + *offset = 0; + } } + Ordering::Equal => (), } } diff --git a/src/commands/line_nums.rs b/src/commands/line_nums.rs index af26e3f..c5ff877 100644 --- a/src/commands/line_nums.rs +++ b/src/commands/line_nums.rs @@ -4,10 +4,7 @@ use crate::error::JoshutoResult; use super::reload; -pub fn switch_line_numbering( - context: &mut AppContext, - style: LineNumberStyle, -) -> JoshutoResult<()> { +pub fn switch_line_numbering(context: &mut AppContext, style: LineNumberStyle) -> JoshutoResult { context .config_mut() .display_options_mut() diff --git a/src/commands/new_directory.rs b/src/commands/new_directory.rs index 8364d93..1f56521 100644 --- a/src/commands/new_directory.rs +++ b/src/commands/new_directory.rs @@ -4,7 +4,7 @@ use crate::context::AppContext; use crate::error::JoshutoResult; use crate::history::DirectoryHistory; -pub fn new_directory(context: &mut AppContext, p: &path::Path) -> JoshutoResult<()> { +pub fn new_directory(context: &mut AppContext, p: &path::Path) -> JoshutoResult { std::fs::create_dir_all(p)?; let options = context.config_ref().display_options_ref().clone(); let curr_path = context.tab_context_ref().curr_tab_ref().cwd().to_path_buf(); diff --git a/src/commands/numbered_command.rs b/src/commands/numbered_command.rs index 39775e6..16e3991 100644 --- a/src/commands/numbered_command.rs +++ b/src/commands/numbered_command.rs @@ -15,7 +15,7 @@ pub fn numbered_command( context: &mut AppContext, backend: &mut TuiBackend, keymap: &AppKeyMapping, -) -> JoshutoResult<()> { +) -> JoshutoResult { context.flush_event(); let mut prefix = String::from(first_char); diff --git a/src/commands/open_file.rs b/src/commands/open_file.rs index 3a2f0f2..3da11db 100644 --- a/src/commands/open_file.rs +++ b/src/commands/open_file.rs @@ -23,7 +23,7 @@ pub fn get_options<'a>(path: &path::Path) -> Vec<&'a AppMimetypeEntry> { options } -pub fn open(context: &mut AppContext, backend: &mut TuiBackend) -> JoshutoResult<()> { +pub fn open(context: &mut AppContext, backend: &mut TuiBackend) -> JoshutoResult { let config = context.config_ref(); if let Some(entry) = context @@ -146,10 +146,7 @@ where } } -pub fn open_with_interactive( - context: &mut AppContext, - backend: &mut TuiBackend, -) -> JoshutoResult<()> { +pub fn open_with_interactive(context: &mut AppContext, backend: &mut TuiBackend) -> JoshutoResult { let paths = context .tab_context_ref() .curr_tab_ref() @@ -173,7 +170,7 @@ pub fn open_with_index( context: &mut AppContext, backend: &mut TuiBackend, index: usize, -) -> JoshutoResult<()> { +) -> JoshutoResult { let paths = context .tab_context_ref() .curr_tab_ref() diff --git a/src/commands/parent_cursor_move.rs b/src/commands/parent_cursor_move.rs index 3bab3d3..febd391 100644 --- a/src/commands/parent_cursor_move.rs +++ b/src/commands/parent_cursor_move.rs @@ -3,7 +3,7 @@ use std::path::PathBuf; use crate::context::AppContext; use crate::error::JoshutoResult; -pub fn parent_cursor_move(context: &mut AppContext, new_index: usize) -> JoshutoResult<()> { +pub fn parent_cursor_move(context: &mut AppContext, new_index: usize) -> JoshutoResult { let mut path: Option<PathBuf> = None; let mut new_index = new_index; @@ -31,7 +31,7 @@ pub fn parent_cursor_move(context: &mut AppContext, new_index: usize) -> Joshuto Ok(()) } -pub fn parent_up(context: &mut AppContext, u: usize) -> JoshutoResult<()> { +pub fn parent_up(context: &mut AppContext, u: usize) -> JoshutoResult { let movement = match context.tab_context_ref().curr_tab_ref().parent_list_ref() { Some(list) => list .get_index() @@ -46,7 +46,7 @@ pub fn parent_up(context: &mut AppContext, u: usize) -> JoshutoResult<()> { Ok(()) } -pub fn parent_down(context: &mut AppContext, u: usize) -> JoshutoResult<()> { +pub fn parent_down(context: &mut AppContext, u: usize) -> JoshutoResult { let movement = match context.tab_context_ref().curr_tab_ref().parent_list_ref() { Some(list) => list.get_index().map(|idx| idx + u), None => None, diff --git a/src/commands/preview_cursor_move.rs b/src/commands/preview_cursor_move.rs index c9c7238..d57b315 100644 --- a/src/commands/preview_cursor_move.rs +++ b/src/commands/preview_cursor_move.rs @@ -3,7 +3,7 @@ use std::path::PathBuf; use crate::context::AppContext; use crate::error::JoshutoResult; -fn preview_cursor_move(context: &mut AppContext, new_index: usize) -> JoshutoResult<()> { +fn preview_cursor_move(context: &mut AppContext, new_index: usize) -> JoshutoResult { let file_path: Option<PathBuf> = { let curr_tab = context.tab_context_ref().curr_tab_ref(); let curr_list = curr_tab.curr_list_ref(); @@ -20,7 +20,7 @@ fn preview_cursor_move(context: &mut AppContext, new_index: usize) -> JoshutoRes Ok(()) } -pub fn preview_up(context: &mut AppContext, u: usize) -> JoshutoResult<()> { +pub fn preview_up(context: &mut AppContext, u: usize) -> JoshutoResult { let new_index = { let curr_tab = context.tab_context_ref().curr_tab_ref(); let curr_list = curr_tab.curr_list_ref(); @@ -49,7 +49,7 @@ pub fn preview_up(context: &mut AppContext, u: usize) -> JoshutoResult<()> { Ok(()) } -pub fn preview_down(context: &mut AppContext, u: usize) -> JoshutoResult<()> { +pub fn preview_down(context: &mut AppContext, u: usize) -> JoshutoResult { let new_index = { let curr_tab = context.tab_context_ref().curr_tab_ref(); let curr_list = curr_tab.curr_list_ref(); diff --git a/src/commands/quit.rs b/src/commands/quit.rs index 214a2bd..0d3d31a 100644 --- a/src/commands/quit.rs +++ b/src/commands/quit.rs @@ -3,7 +3,7 @@ use std::io; use crate::context::{AppContext, QuitType}; use crate::error::{JoshutoError, JoshutoErrorKind, JoshutoResult}; -pub fn quit(context: &mut AppContext) -> JoshutoResult<()> { +pub fn quit(context: &mut AppContext) -> JoshutoResult { let worker_context = context.worker_context_ref(); if worker_context.is_busy() || !worker_context.is_empty() { Err(JoshutoError::new( @@ -16,7 +16,7 @@ pub fn quit(context: &mut AppContext) -> JoshutoResult<()> { } } -pub fn quit_to_current_directory(context: &mut AppContext) -> JoshutoResult<()> { +pub fn quit_to_current_directory(context: &mut AppContext) -> JoshutoResult { let worker_context = context.worker_context_ref(); if worker_context.is_busy() || !worker_context.is_empty() { Err(JoshutoError::new( @@ -29,7 +29,7 @@ pub fn quit_to_current_directory(context: &mut AppContext) -> JoshutoResult<()> } } -pub fn force_quit(context: &mut AppContext) -> JoshutoResult<()> { +pub fn force_quit(context: &mut AppContext) -> JoshutoResult { context.quit = QuitType::Force; Ok(()) } diff --git a/src/commands/reload.rs b/src/commands/reload.rs index d1e0698..f9d423b 100644 --- a/src/commands/reload.rs +++ b/src/commands/reload.rs @@ -72,7 +72,7 @@ pub fn reload(context: &mut AppContext, index: usize) -> std::io::Result<()> { Ok(()) } -pub fn reload_dirlist(context: &mut AppContext) -> JoshutoResult<()> { +pub fn reload_dirlist(context: &mut AppContext) -> JoshutoResult { reload(context, context.tab_context_ref().index)?; Ok(()) } diff --git a/src/commands/rename_file.rs b/src/commands/rename_file.rs index 0c5005a..981cfcf 100644 --- a/src/commands/rename_file.rs +++ b/src/commands/rename_file.rs @@ -36,7 +36,7 @@ pub fn _rename_file( Ok(()) } -pub fn rename_file(context: &mut AppContext, dest: &path::Path) -> JoshutoResult<()> { +pub fn rename_file(context: &mut AppContext, dest: &path::Path) -> JoshutoResult { let path: Option<path::PathBuf> = context .tab_context_ref() .curr_tab_ref() @@ -55,7 +55,7 @@ pub fn _rename_file_append( backend: &mut TuiBackend, keymap_t: &AppKeyMapping, file_name: &str, -) -> JoshutoResult<()> { +) -> JoshutoResult { let (prefix, suffix): (String, String) = match file_name.rfind('.') { Some(ext) => ( format!("rename {}", &file_name[0..ext]), @@ -70,7 +70,7 @@ pub fn rename_file_append( context: &mut AppContext, backend: &mut TuiBackend, keymap_t: &AppKeyMapping, -) -> JoshutoResult<()> { +) -> JoshutoResult { let mut file_name: Option<String> = None; if let Some(curr_list) = context.tab_context_ref().curr_tab_ref().curr_list_ref() { @@ -90,7 +90,7 @@ pub fn _rename_file_prepend( backend: &mut TuiBackend, keymap_t: &AppKeyMapping, file_name: String, -) -> JoshutoResult<()> { +) -> JoshutoResult { let prefix = String::from("rename "); let suffix = file_name; command_line::read_and_execute(context, backend, keymap_t, &prefix, &suffix) @@ -100,7 +100,7 @@ pub fn rename_file_prepend( context: &mut AppContext, backend: &mut TuiBackend, keymap_t: &AppKeyMapping, -) -> JoshutoResult<()> { +) -> JoshutoResult { let mut file_name: Option<String> = None; if let Some(curr_list) = context.tab_context_ref().curr_tab_ref().curr_list_ref() { diff --git a/src/commands/search.rs b/src/commands/search.rs index 81cfd79..0d3fbdc 100644 --- a/src/commands/search.rs +++ b/src/commands/search.rs @@ -6,7 +6,7 @@ use super::cursor_move; use super::search_glob; use super::search_string; -pub fn search_next(context: &mut AppContext) -> JoshutoResult<()> { +pub fn search_next(context: &mut AppContext) -> JoshutoResult { if let Some(search_context) = context.get_search_context() { let index = match search_context { SearchPattern::Glob(s) => { @@ -23,7 +23,7 @@ pub fn search_next(context: &mut AppContext) -> JoshutoResult<()> { Ok(()) } -pub fn search_prev(context: &mut AppContext) -> JoshutoResult<()> { +pub fn search_prev(context: &mut AppContext) -> JoshutoResult { if let Some(search_context) = context.get_search_context() { let index = match search_context { SearchPattern::Glob(s) => { diff --git a/src/commands/search_fzf.rs b/src/commands/search_fzf.rs index 6512cf4..0ae9fae 100644 --- a/src/commands/search_fzf.rs +++ b/src/commands/search_fzf.rs @@ -7,7 +7,7 @@ use crate::context::AppContext; use crate::error::{JoshutoError, JoshutoErrorKind, JoshutoResult}; use crate::ui::TuiBackend; -pub fn search_fzf(context: &mut AppContext, backend: &mut TuiBackend) -> JoshutoResult<()> { +pub fn search_fzf(context: &mut AppContext, backend: &mut TuiBackend) -> JoshutoResult { let items = context .tab_context_ref() .curr_tab_ref() @@ -16,7 +16,7 @@ pub fn search_fzf(context: &mut AppContext, backend: &mut TuiBackend) -> Joshuto let v: Vec<String> = list .iter() .enumerate() - .map(|(i, entry)| format!("{} {}\n", i, entry.file_name().to_string())) + .map(|(i, entry)| format!("{} {}\n", i, entry.file_name())) .collect(); v }) @@ -36,14 +36,11 @@ pub fn search_fzf(context: &mut AppContext, backend: &mut TuiBackend) -> Joshuto .stdout(Stdio::piped()) .spawn()?; - match fzf.stdin.as_mut() { - Some(fzf_stdin) => { - let mut writer = io::BufWriter::new(fzf_stdin); - for item in items { - writer.write_all(item.as_bytes())?; - } + if let Some(fzf_stdin) = fzf.stdin.as_mut() { + let mut writer = io::BufWriter::new(fzf_stdin); + for item in items { + writer.write_all(item.as_bytes())?; } - None => {} } let fzf_output = fzf.wait_with_output(); diff --git a/src/commands/search_glob.rs b/src/commands/search_glob.rs index c761523..61140ee 100644 --- a/src/commands/search_glob.rs +++ b/src/commands/search_glob.rs @@ -34,7 +34,7 @@ pub fn search_glob_rev(curr_tab: &JoshutoTab, glob: &GlobMatcher) -> Option<usiz None } -pub fn search_glob(context: &mut AppContext, pattern: &str) -> JoshutoResult<()> { +pub fn search_glob(context: &mut AppContext, pattern: &str) -> JoshutoResult { let glob = GlobBuilder::new(pattern) .case_insensitive(true) .build()? diff --git a/src/commands/selection.rs b/src/commands/selection.rs index dc78136..99f2471 100644 --- a/src/commands/selection.rs +++ b/src/commands/selection.rs @@ -10,7 +10,7 @@ pub fn select_files( context: &mut AppContext, pattern: &str, options: &SelectOption, -) -> JoshutoResult<()> { +) -> JoshutoResult { if pattern.is_empty() { select_without_pattern(context, options) } else { @@ -18,7 +18,7 @@ pub fn select_files( } } -fn select_without_pattern(context: &mut AppContext, options: &SelectOption) -> JoshutoResult<()> { +fn select_without_pattern(context: &mut AppContext, options: &SelectOption) -> JoshutoResult { if options.all { if let Some(curr_list) = context.tab_context_mut().curr_tab_mut().curr_list_mut() { curr_list.iter_mut().for_each(|e| { @@ -53,7 +53,7 @@ fn select_with_pattern( context: &mut AppContext, pattern: &str, options: &SelectOption, -) -> JoshutoResult<()> { +) -> JoshutoResult { let glob = Glob::new(pattern)?.compile_matcher(); if let Some(curr_list) = context.tab_context_mut().curr_tab_mut().curr_list_mut() { diff --git a/src/commands/set_mode.rs b/src/commands/set_mode.rs index b7e6e33..2691483 100644 --- a/src/commands/set_mode.rs +++ b/src/commands/set_mode.rs @@ -35,7 +35,7 @@ pub fn str_to_mode(s: &str) -> u32 { mode } -pub fn set_mode(context: &mut AppContext, backend: &mut TuiBackend) -> JoshutoResult<()> { +pub fn set_mode(context: &mut AppContext, backend: &mut TuiBackend) -> JoshutoResult { #[cfg(unix)] use std::os::unix::fs::PermissionsExt; diff --git a/src/commands/show_hidden.rs b/src/commands/show_hidden.rs index 9108760..f0c437c 100644 --- a/src/commands/show_hidden.rs +++ b/src/commands/show_hidden.rs @@ -19,7 +19,7 @@ pub fn _toggle_hidden(context: &mut AppContext) { } } -pub fn toggle_hidden(context: &mut AppContext) -> JoshutoResult<()> { +pub fn toggle_hidden(context: &mut AppContext) -> JoshutoResult { _toggle_hidden(context); reload::reload_dirlist(context) } diff --git a/src/commands/show_workers.rs b/src/commands/show_workers.rs index 82c3aa2..cc6c65c 100644 --- a/src/commands/show_workers.rs +++ b/src/commands/show_workers.rs @@ -12,7 +12,7 @@ pub fn show_workers( context: &mut AppContext, backend: &mut TuiBackend, _keymap_t: &AppKeyMapping, -) -> JoshutoResult<()> { +) -> JoshutoResult { context.flush_event(); loop { @@ -21,6 +21,7 @@ pub fn show_workers( if let Ok(event) = context.poll_event() { match event { AppEvent::Termion(event) => { + #[allow(clippy::single_match)] match event { Event::Key(Key::Esc) => break, _ => {} diff --git a/src/commands/sort.rs b/src/commands/sort.rs index ba9f103..ace9daf 100644 --- a/src/commands/sort.rs +++ b/src/commands/sort.rs @@ -5,7 +5,7 @@ use crate::history::DirectoryHistory; use super::reload; -pub fn set_sort(context: &mut AppContext, method: SortType) -> JoshutoResult<()> { +pub fn set_sort(context: &mut AppContext, method: SortType) -> JoshutoResult { context .config_mut() .sort_options_mut() @@ -16,7 +16,7 @@ pub fn set_sort(context: &mut AppContext, method: SortType) -> JoshutoResult<()> refresh(context) } -pub fn toggle_reverse(context: &mut AppContext) -> JoshutoResult<()> { +pub fn toggle_reverse(context: &mut AppContext) -> JoshutoResult { let reversed = !context.config_ref().sort_options_ref().reverse; context.config_mut().sort_options_mut().reverse = reversed; @@ -26,7 +26,7 @@ pub fn toggle_reverse(context: &mut AppContext) -> JoshutoResult<()> { refresh(context) } -fn refresh(context: &mut AppContext) -> JoshutoResult<()> { +fn refresh(context: &mut AppContext) -> JoshutoResult { reload::soft_reload(context.tab_context_ref().index, context)?; Ok(()) } diff --git a/src/commands/sub_process.rs b/src/commands/sub_process.rs index c69dfff..08629ab 100644 --- a/src/commands/sub_process.rs +++ b/src/commands/sub_process.rs @@ -49,7 +49,7 @@ pub fn sub_process( backend: &mut TuiBackend, words: &[String], spawn: bool, -) -> JoshutoResult<()> { +) -> JoshutoResult { backend.terminal_drop(); let res = execute_sub_process(context, words, spawn); reload::soft_reload(context.tab_context_ref().index, context)?; diff --git a/src/commands/subdir_fzf.rs b/src/commands/subdir_fzf.rs index 51de88f..d1adc07 100644 --- a/src/commands/subdir_fzf.rs +++ b/src/commands/subdir_fzf.rs @@ -9,7 +9,7 @@ use crate::ui::TuiBackend; use super::change_directory::change_directory; -pub fn subdir_fzf(context: &mut AppContext, backend: &mut TuiBackend) -> JoshutoResult<()> { +pub fn subdir_fzf(context: &mut AppContext, backend: &mut TuiBackend) -> JoshutoResult { let fzf_default_command = std::env::var("FZF_DEFAULT_COMMAND")?; backend.terminal_drop(); @@ -20,12 +20,9 @@ pub fn subdir_fzf(context: &mut AppContext, backend: &mut TuiBackend) -> Joshuto .stdout(Stdio::piped()) .spawn()?; - match fzf_results.stdin.as_mut() { - Some(fzf_stdin) => { - let mut writer = io::BufWriter::new(fzf_stdin); - writer.write_all(fzf_default_command.as_bytes())?; - } - None => {} + if let Some(fzf_stdin) = fzf_results.stdin.as_mut() { + let mut writer = io::BufWriter::new(fzf_stdin); + writer.write_all(fzf_default_command.as_bytes())?; } fzf_results.wait_with_output()? }; @@ -35,12 +32,9 @@ pub fn subdir_fzf(context: &mut AppContext, backend: &mut TuiBackend) -> Joshuto .stdout(Stdio::piped()) .spawn()?; - match fzf.stdin.as_mut() { - Some(fzf_stdin) => { - let mut writer = io::BufWriter::new(fzf_stdin); - writer.write_all(&fzf_default_command_output.stdout)?; - } - None => {} + if let Some(fzf_stdin) = fzf.stdin.as_mut() { + let mut writer = io::BufWriter::new(fzf_stdin); + writer.write_all(&fzf_default_command_output.stdout)?; } let fzf_output = fzf.wait_with_output(); @@ -59,7 +53,7 @@ pub fn subdir_fzf(context: &mut AppContext, backend: &mut TuiBackend) -> Joshuto Ok(()) } -pub fn fzf_change_dir(context: &mut AppContext, path: &Path) -> JoshutoResult<()> { +pub fn fzf_change_dir(context: &mut AppContext, path: &Path) -> JoshutoResult { if path.is_dir() { change_directory(context, path)?; } else if let Some(parent) = path.parent() { diff --git a/src/commands/tab_ops.rs b/src/commands/tab_ops.rs index dd27998..ef87e7a 100644 --- a/src/commands/tab_ops.rs +++ b/src/commands/tab_ops.rs @@ -66,7 +66,7 @@ pub fn tab_switch(offset: i32, context: &mut AppContext) -> std::io::Result<()> _tab_switch(new_index, context) } -pub fn tab_switch_index(new_index: usize, context: &mut AppContext) -> JoshutoResult<()> { +pub fn tab_switch_index(new_index: usize, context: &mut AppContext) -> JoshutoResult { if new_index <= context.tab_context_ref().len() { _tab_switch(new_index - 1, context)?; Ok(()) @@ -93,7 +93,7 @@ pub fn new_tab_home_path(context: &AppContext) -> path::PathBuf { } } -pub fn new_tab(context: &mut AppContext) -> JoshutoResult<()> { +pub fn new_tab(context: &mut AppContext) -> JoshutoResult { let new_tab_path = new_tab_home_path(context); let tab = JoshutoTa |