diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/app/app.rs | 8 | ||||
-rw-r--r-- | src/app/app_context.rs | 4 | ||||
-rw-r--r-- | src/app/panel_state.rs | 3 | ||||
-rw-r--r-- | src/app/selection.rs | 2 | ||||
-rw-r--r-- | src/browser/browser_state.rs | 4 | ||||
-rw-r--r-- | src/command/panel_input.rs | 2 | ||||
-rw-r--r-- | src/help/help_verbs.rs | 2 | ||||
-rw-r--r-- | src/kitty/mod.rs | 2 | ||||
-rw-r--r-- | src/pattern/fuzzy_pattern.rs | 2 | ||||
-rw-r--r-- | src/preview/preview_state.rs | 8 | ||||
-rw-r--r-- | src/print.rs | 4 | ||||
-rw-r--r-- | src/stage/filtered_stage.rs | 4 | ||||
-rw-r--r-- | src/tree/tree.rs | 4 | ||||
-rw-r--r-- | src/tree_build/builder.rs | 8 |
14 files changed, 28 insertions, 29 deletions
diff --git a/src/app/app.rs b/src/app/app.rs index 18914a8..df1ab2c 100644 --- a/src/app/app.rs +++ b/src/app/app.rs @@ -35,7 +35,7 @@ use { }, std::{ io::Write, - path::PathBuf, + path::{Path, PathBuf}, str::FromStr, sync::{ Arc, @@ -280,7 +280,7 @@ impl App { if let Some(preview_id) = self.preview_panel { for (idx, panel) in self.panels.iter().enumerate() { if self.active_panel_idx != idx && panel.id != preview_id { - return panel.state().selected_path().map(|p| p.to_path_buf()); + return panel.state().selected_path().map(Path::to_path_buf); } } } @@ -290,7 +290,7 @@ impl App { self.panels[non_focused_panel_idx] .state() .selected_path() - .map(|p| p.to_path_buf()) + .map(Path::to_path_buf) } else { None } @@ -774,7 +774,7 @@ impl App { } fn has_pending_task(&mut self) -> bool { - self.panels.iter().any(|p| p.has_pending_task()) + self.panels.iter().any(Panel::has_pending_task) } /// This is the main loop of the application diff --git a/src/app/app_context.rs b/src/app/app_context.rs index b27e537..8508286 100644 --- a/src/app/app_context.rs +++ b/src/app/app_context.rs @@ -163,7 +163,7 @@ impl AppContext { let search_modes = config .search_modes .as_ref() - .map(|map| map.try_into()) + .map(TryInto::try_into) .transpose()? .unwrap_or_default(); let ext_colors = ExtColorMap::try_from(&config.ext_colors) @@ -248,7 +248,7 @@ impl AppContext { pub fn cmd(&self) -> Option<&str> { self.launch_args.cmd.as_ref().or( self.config_default_args.as_ref().and_then(|args| args.cmd.as_ref()) - ).map(|s| s.as_str()) + ).map(String::as_str) } pub fn initial_mode(&self) -> Mode { if self.modal { diff --git a/src/app/panel_state.rs b/src/app/panel_state.rs index 20d870b..62167a4 100644 --- a/src/app/panel_state.rs +++ b/src/app/panel_state.rs @@ -673,8 +673,7 @@ pub trait PanelState { } else { let line = input_invocation .and_then(|inv| inv.args.as_ref()) - .map(|s| s.as_str()) - .unwrap_or(""); + .map_or("", String::as_str); verb_write(con, line)?; } CmdResult::Keep diff --git a/src/app/selection.rs b/src/app/selection.rs index e81804c..51d279d 100644 --- a/src/app/selection.rs +++ b/src/app/selection.rs @@ -118,7 +118,7 @@ impl<'a> SelInfo<'a> { SelInfo::None => true, SelInfo::One(sel) => condition.accepts_path(sel.path), SelInfo::More(stage) => { - for path in stage.paths().iter() { + for path in stage.paths() { if !condition.accepts_path(path) { return false; } diff --git a/src/browser/browser_state.rs b/src/browser/browser_state.rs index bf82d7b..e87446d 100644 --- a/src/browser/browser_state.rs +++ b/src/browser/browser_state.rs @@ -396,7 +396,7 @@ impl PanelState for BrowserState { } Internal::next_dir => { self.displayed_tree_mut().try_select_next_filtered( - |line| line.is_dir(), + TreeLine::is_dir, page_height, ); CmdResult::Keep @@ -474,7 +474,7 @@ impl PanelState for BrowserState { Internal::parent => self.go_to_parent(screen, con, bang), Internal::previous_dir => { self.displayed_tree_mut().try_select_previous_filtered( - |line| line.is_dir(), + TreeLine::is_dir, page_height, ); CmdResult::Keep diff --git a/src/command/panel_input.rs b/src/command/panel_input.rs index 8c903f0..aae6793 100644 --- a/src/command/panel_input.rs +++ b/src/command/panel_input.rs @@ -285,7 +285,7 @@ impl PanelInput { sel_info: SelInfo<'_>, panel_state_type: PanelStateType, ) -> Option<&'c Verb> { - for verb in con.verb_store.verbs().iter() { + for verb in con.verb_store.verbs() { // note that there can be several verbs with the same key and // not all of them can apply if !verb.keys.contains(&key) { diff --git a/src/help/help_verbs.rs b/src/help/help_verbs.rs index 795f9f3..a557bfc 100644 --- a/src/help/help_verbs.rs +++ b/src/help/help_verbs.rs @@ -46,7 +46,7 @@ pub fn matching_verb_rows<'v>( con: &'v AppContext, ) -> Vec<MatchingVerbRow<'v>> { let mut rows = Vec::new(); - for verb in con.verb_store.verbs().iter() { + for verb in con.verb_store.verbs() { if !verb.show_in_doc { continue; } diff --git a/src/kitty/mod.rs b/src/kitty/mod.rs index 8c5360a..68172e0 100644 --- a/src/kitty/mod.rs +++ b/src/kitty/mod.rs @@ -95,7 +95,7 @@ impl KittyManager { kept_id: KittyImageId, drawing_count: usize, ) { - for image in self.rendered_images.iter_mut() { + for image in &mut self.rendered_images { if image.image_id == kept_id { image.drawing_count = drawing_count; } diff --git a/src/pattern/fuzzy_pattern.rs b/src/pattern/fuzzy_pattern.rs index 12aaec2..fafe9a0 100644 --- a/src/pattern/fuzzy_pattern.rs +++ b/src/pattern/fuzzy_pattern.rs @@ -30,7 +30,7 @@ pub struct FuzzyPattern { impl fmt::Display for FuzzyPattern { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - for &c in self.chars.iter() { + for &c in &self.chars { f.write_char(c)? } Ok(()) diff --git a/src/preview/preview_state.rs b/src/preview/preview_state.rs index eb180be..e39bcb2 100644 --- a/src/preview/preview_state.rs +++ b/src/preview/preview_state.rs @@ -20,9 +20,9 @@ use { }; /// an application state dedicated to previewing files. -/// It's usually the only state in its panel and is kept when -/// the selection changes (other panels indirectly call -/// set_selected_path). +/// +/// It's usually the only state in its panel and is kept when the +/// selection changes (other panels indirectly call `set_selected_path`). pub struct PreviewState { pub preview_area: Area, dirty: bool, // true when background must be cleared @@ -200,7 +200,7 @@ impl PanelState for PreviewState { self.pending_pattern = fp.pattern(); }; self.transform = con.preview_transformers.transform(&path, self.preferred_mode); - let preview_path = self.transform.as_ref().map(|c| &c.output_path).unwrap_or(&path); + let preview_path = self.transform.as_ref().map_or(&path, |c| &c.output_path); self.preview = Preview::new(preview_path, self.preferred_mode, con); if let Some(number) = selected_line_number { self.preview.try_select_line_number(number); diff --git a/src/print.rs b/src/print.rs index 6775401..9b31d99 100644 --- a/src/print.rs +++ b/src/print.rs @@ -32,7 +32,7 @@ pub fn print_paths(sel_info: SelInfo, con: &AppContext) -> io::Result<CmdResult> SelInfo::One(sel) => sel.path.to_string_lossy().to_string(), SelInfo::More(stage) => { let mut string = String::new(); - for path in stage.paths().iter() { + for path in stage.paths() { string.push_str(&path.to_string_lossy()); string.push('\n'); } @@ -67,7 +67,7 @@ pub fn print_relative_paths(sel_info: SelInfo, con: &AppContext) -> io::Result<C SelInfo::One(sel) => relativize_path(sel.path, con)?, SelInfo::More(stage) => { let mut string = String::new(); - for path in stage.paths().iter() { + for path in stage.paths() { string.push_str(&relativize_path(path, con)?); string.push('\n'); } diff --git a/src/stage/filtered_stage.rs b/src/stage/filtered_stage.rs index dab2ba3..3132b61 100644 --- a/src/stage/filtered_stage.rs +++ b/src/stage/filtered_stage.rs @@ -5,7 +5,7 @@ use { }, std::{ convert::TryFrom, - path::Path, + path::{Path, PathBuf}, }, }; @@ -93,7 +93,7 @@ impl FilteredStage { self.paths_idx .get(idx) .and_then(|&idx| stage.paths().get(idx)) - .map(|p| p.as_path()) + .map(PathBuf::as_path) } pub fn path_sel<'s>(&self, stage: &'s Stage, idx: usize) -> Option<(&'s Path, bool)> { self.path(stage, idx) diff --git a/src/tree/tree.rs b/src/tree/tree.rs index 94a11f9..68cb505 100644 --- a/src/tree/tree.rs +++ b/src/tree/tree.rs @@ -75,14 +75,14 @@ impl Tree { // - a node can come from a not parent node, when we followed a link let mut bid_parents: FxHashMap<BId, BId> = FxHashMap::default(); let mut bid_lines: FxHashMap<BId, &TreeLine> = FxHashMap::default(); - for line in self.lines[..].iter() { + for line in &self.lines[..] { if let Some(parent_bid) = line.parent_bid { bid_parents.insert(line.bid, parent_bid); } bid_lines.insert(line.bid, line); } let mut sort_paths: FxHashMap<BId, String> = FxHashMap::default(); - for line in self.lines[1..].iter() { + for line in &self.lines[1..] { let mut sort_path = String::new(); let mut bid = line.bid; while let Some(l) = bid_lines.get(&bid) { diff --git a/src/tree_build/builder.rs b/src/tree_build/builder.rs index 65fe9a4..c52c117 100644 --- a/src/tree_build/builder.rs +++ b/src/tree_build/builder.rs @@ -424,7 +424,7 @@ impl<'c> TreeBuilder<'c> { out_blines: &[BId], ) { let mut count = 1; - for id in out_blines[1..].iter() { + for id in &out_blines[1..] { if self.blines[*id].has_match { //debug!("bline before trimming: {:?}", &self.blines[*idx].path); count += 1; @@ -434,7 +434,7 @@ impl<'c> TreeBuilder<'c> { } } let mut remove_queue: BinaryHeap<SortableBId> = BinaryHeap::new(); - for id in out_blines[1..].iter() { + for id in &out_blines[1..] { let bline = &self.blines[*id]; if bline.has_match && bline.nb_kept_children == 0 @@ -533,7 +533,7 @@ impl<'c> TreeBuilder<'c> { out_blines: &[BId], ) -> Tree { let mut lines: Vec<TreeLine> = Vec::new(); - for id in out_blines.iter() { + for id in out_blines { if self.blines[*id].has_match { // we need to count the children, so we load them if self.blines[*id].can_enter() && self.blines[*id].children.is_none() { @@ -566,7 +566,7 @@ impl<'c> TreeBuilder<'c> { tree.git_status = ComputationResult::NotComputed; // it would make no sense to keep only files having a git status and // not display that type - for line in tree.lines.iter_mut() { + for line in &mut tree.lines { line.git_status = computer.line_status(&line.path); } } |