aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordiogo464 <[email protected]>2022-09-23 13:53:30 +0100
committerdiogo464 <[email protected]>2022-09-23 13:56:22 +0100
commit8f3b3dc4679a361f31a4d790372f2baf53a115bd (patch)
tree6d15998bc0c8990d6a3d73d7e746260f51fc4c6f
parentbd4934dd6d0b141ec699949c1e14b12e8ae9d08f (diff)
clippy fixes
-rw-r--r--src/dotup/action_tree.rs18
-rw-r--r--src/dotup/cfg.rs3
-rw-r--r--src/dotup/mod.rs22
3 files changed, 16 insertions, 27 deletions
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 {
55 55
56// -------------------- TreeNodeKind -------------------- // 56// -------------------- TreeNodeKind -------------------- //
57 57
58#[allow(unused)]
58impl TreeNodeKind { 59impl TreeNodeKind {
59 fn as_action(&self) -> ActionID { 60 fn as_action(&self) -> ActionID {
60 match self { 61 match self {
@@ -116,7 +117,7 @@ impl ActionTree {
116 path: target.to_owned(), 117 path: target.to_owned(),
117 action, 118 action,
118 }); 119 });
119 self.force_insert_at(&target, TreeNodeKind::Action(action_id)); 120 self.force_insert_at(target, TreeNodeKind::Action(action_id));
120 action_id 121 action_id
121 } 122 }
122 123
@@ -166,7 +167,7 @@ impl ActionTree {
166 log::trace!("creating symlink {:?} -> {:?}", source, target); 167 log::trace!("creating symlink {:?} -> {:?}", source, target);
167 std::os::unix::fs::symlink(source, target)?; 168 std::os::unix::fs::symlink(source, target)?;
168 } 169 }
169 Action::Copy { source } => todo!(), 170 Action::Copy { source: _ } => todo!(),
170 } 171 }
171 Ok(()) 172 Ok(())
172 } 173 }
@@ -193,10 +194,6 @@ impl ActionTree {
193 Ok(()) 194 Ok(())
194 } 195 }
195 196
196 pub fn actions(&self) -> impl Iterator<Item = &TreeAction> {
197 self.actions.values()
198 }
199
200 pub fn action_ids(&self) -> impl Iterator<Item = ActionID> + '_ { 197 pub fn action_ids(&self) -> impl Iterator<Item = ActionID> + '_ {
201 self.actions.keys() 198 self.actions.keys()
202 } 199 }
@@ -250,13 +247,10 @@ impl ActionTree {
250 } 247 }
251 } 248 }
252 let prev_kind = std::mem::replace(&mut self.nodes[curr].kind, kind); 249 let prev_kind = std::mem::replace(&mut self.nodes[curr].kind, kind);
253 match prev_kind { 250 if let TreeNodeKind::SubTree(children) = prev_kind {
254 TreeNodeKind::SubTree(children) => { 251 for &child in children.iter() {
255 for &child in children.iter() { 252 self.remove_node(child);
256 self.remove_node(child);
257 }
258 } 253 }
259 _ => {}
260 } 254 }
261 curr 255 curr
262 } 256 }
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<Span<'s>> for ParseError {
138 Self::new(location_from_span(input), format!("error kind: {kind:?}")) 138 Self::new(location_from_span(input), format!("error kind: {kind:?}"))
139 } 139 }
140 140
141 fn append(input: Span, kind: nom::error::ErrorKind, other: Self) -> Self { 141 fn append(_input: Span, _kind: nom::error::ErrorKind, other: Self) -> Self {
142 other 142 other
143 } 143 }
144 144
@@ -195,6 +195,7 @@ impl std::fmt::Display for Location {
195} 195}
196 196
197impl KeyValue { 197impl KeyValue {
198 #[allow(unused)]
198 fn new(key: impl Into<String>, value: impl Into<String>) -> Self { 199 fn new(key: impl Into<String>, value: impl Into<String>) -> Self {
199 Self { 200 Self {
200 key: key.into(), 201 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::{
8 path::{Path, PathBuf}, 8 path::{Path, PathBuf},
9}; 9};
10 10
11use slotmap::{Key, SlotMap}; 11use slotmap::SlotMap;
12use thiserror::Error; 12use thiserror::Error;
13 13
14pub use paths::*; 14pub use paths::*;
@@ -162,7 +162,7 @@ impl Dotup {
162 } 162 }
163 163
164 fn find_group_by_name_rooted(&self, root: GroupID, name: &str) -> Option<GroupID> { 164 fn find_group_by_name_rooted(&self, root: GroupID, name: &str) -> Option<GroupID> {
165 let trimmed = name.trim_start_matches("."); 165 let trimmed = name.trim_start_matches('.');
166 let rel_levels = name.len() - trimmed.len(); 166 let rel_levels = name.len() - trimmed.len();
167 let mut current = self.root_id; 167 let mut current = self.root_id;
168 168
@@ -176,7 +176,7 @@ impl Dotup {
176 } 176 }
177 } 177 }
178 178
179 for comp in trimmed.split(".") { 179 for comp in trimmed.split('.') {
180 let group = &self.groups[current]; 180 let group = &self.groups[current];
181 let child_id = group.children.get(comp)?; 181 let child_id = group.children.get(comp)?;
182 current = *child_id; 182 current = *child_id;
@@ -204,12 +204,9 @@ impl Dotup {
204 .items 204 .items
205 .drain_filter(|item| std::matches!(item, cfg::GroupItem::Action(_))) 205 .drain_filter(|item| std::matches!(item, cfg::GroupItem::Action(_)))
206 { 206 {
207 match item { 207 if let cfg::GroupItem::Action(action) = item {
208 cfg::GroupItem::Action(action) => { 208 let action = cfg_action_to_action(action)?;
209 let action = cfg_action_to_action(action)?; 209 group.actions.push(action);
210 group.actions.push(action);
211 }
212 _ => {}
213 } 210 }
214 } 211 }
215 212
@@ -218,11 +215,8 @@ impl Dotup {
218 parent.children.insert(group_cfg.name, group_id); 215 parent.children.insert(group_cfg.name, group_id);
219 216
220 for item in group_cfg.items { 217 for item in group_cfg.items {
221 match item { 218 if let cfg::GroupItem::Group(group) = item {
222 cfg::GroupItem::Group(group) => { 219 self.insert_group(group_id, group)?;
223 self.insert_group(group_id, group)?;
224 }
225 _ => {}
226 } 220 }
227 } 221 }
228 222