From 8f3b3dc4679a361f31a4d790372f2baf53a115bd Mon Sep 17 00:00:00 2001 From: diogo464 Date: Fri, 23 Sep 2022 13:53:30 +0100 Subject: clippy fixes --- src/dotup/action_tree.rs | 18 ++++++------------ src/dotup/cfg.rs | 3 ++- src/dotup/mod.rs | 22 ++++++++-------------- 3 files changed, 16 insertions(+), 27 deletions(-) (limited to 'src') diff --git a/src/dotup/action_tree.rs b/src/dotup/action_tree.rs index de6eee8..44d787e 100644 --- a/src/dotup/action_tree.rs +++ b/src/dotup/action_tree.rs @@ -55,6 +55,7 @@ impl TreeAction { // -------------------- TreeNodeKind -------------------- // +#[allow(unused)] impl TreeNodeKind { fn as_action(&self) -> ActionID { match self { @@ -116,7 +117,7 @@ impl ActionTree { path: target.to_owned(), action, }); - self.force_insert_at(&target, TreeNodeKind::Action(action_id)); + self.force_insert_at(target, TreeNodeKind::Action(action_id)); action_id } @@ -166,7 +167,7 @@ impl ActionTree { log::trace!("creating symlink {:?} -> {:?}", source, target); std::os::unix::fs::symlink(source, target)?; } - Action::Copy { source } => todo!(), + Action::Copy { source: _ } => todo!(), } Ok(()) } @@ -193,10 +194,6 @@ impl ActionTree { Ok(()) } - pub fn actions(&self) -> impl Iterator { - self.actions.values() - } - pub fn action_ids(&self) -> impl Iterator + '_ { self.actions.keys() } @@ -250,13 +247,10 @@ impl ActionTree { } } let prev_kind = std::mem::replace(&mut self.nodes[curr].kind, kind); - match prev_kind { - TreeNodeKind::SubTree(children) => { - for &child in children.iter() { - self.remove_node(child); - } + if let TreeNodeKind::SubTree(children) = prev_kind { + for &child in children.iter() { + self.remove_node(child); } - _ => {} } curr } diff --git a/src/dotup/cfg.rs b/src/dotup/cfg.rs index dbe8769..efa67e2 100644 --- a/src/dotup/cfg.rs +++ b/src/dotup/cfg.rs @@ -138,7 +138,7 @@ impl<'s> nom::error::ParseError> for ParseError { Self::new(location_from_span(input), format!("error kind: {kind:?}")) } - fn append(input: Span, kind: nom::error::ErrorKind, other: Self) -> Self { + fn append(_input: Span, _kind: nom::error::ErrorKind, other: Self) -> Self { other } @@ -195,6 +195,7 @@ impl std::fmt::Display for Location { } impl KeyValue { + #[allow(unused)] fn new(key: impl Into, value: impl Into) -> Self { Self { key: key.into(), diff --git a/src/dotup/mod.rs b/src/dotup/mod.rs index 4e91c2f..445bcfc 100644 --- a/src/dotup/mod.rs +++ b/src/dotup/mod.rs @@ -8,7 +8,7 @@ use std::{ path::{Path, PathBuf}, }; -use slotmap::{Key, SlotMap}; +use slotmap::SlotMap; use thiserror::Error; pub use paths::*; @@ -162,7 +162,7 @@ impl Dotup { } fn find_group_by_name_rooted(&self, root: GroupID, name: &str) -> Option { - let trimmed = name.trim_start_matches("."); + let trimmed = name.trim_start_matches('.'); let rel_levels = name.len() - trimmed.len(); let mut current = self.root_id; @@ -176,7 +176,7 @@ impl Dotup { } } - for comp in trimmed.split(".") { + for comp in trimmed.split('.') { let group = &self.groups[current]; let child_id = group.children.get(comp)?; current = *child_id; @@ -204,12 +204,9 @@ impl Dotup { .items .drain_filter(|item| std::matches!(item, cfg::GroupItem::Action(_))) { - match item { - cfg::GroupItem::Action(action) => { - let action = cfg_action_to_action(action)?; - group.actions.push(action); - } - _ => {} + if let cfg::GroupItem::Action(action) = item { + let action = cfg_action_to_action(action)?; + group.actions.push(action); } } @@ -218,11 +215,8 @@ impl Dotup { parent.children.insert(group_cfg.name, group_id); for item in group_cfg.items { - match item { - cfg::GroupItem::Group(group) => { - self.insert_group(group_id, group)?; - } - _ => {} + if let cfg::GroupItem::Group(group) = item { + self.insert_group(group_id, group)?; } } -- cgit