apply clippy improvements
This commit is contained in:
parent
83ed7ee559
commit
a175e494a1
4 changed files with 10 additions and 6 deletions
|
|
@ -56,7 +56,7 @@ impl DirList {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn from_list(list: &Vec<String>) -> Self {
|
||||
pub fn from_list(list: &[String]) -> Self {
|
||||
Self {
|
||||
safe_source: false,
|
||||
noop: false,
|
||||
|
|
@ -85,7 +85,7 @@ impl DirList {
|
|||
let src_len = self.entries.len();
|
||||
let mut intermediate_files: HashMap<String, String> = HashMap::new();
|
||||
|
||||
self.run_basic_checks(&target_list)?;
|
||||
self.run_basic_checks(target_list)?;
|
||||
if ! self.safe_source {
|
||||
println!("Implement check if target files already exist");
|
||||
}
|
||||
|
|
@ -95,7 +95,7 @@ impl DirList {
|
|||
// is the destination already in the source list?
|
||||
// if so, an intermediate file is needed
|
||||
if self.entries.iter().any(|j| j==&target_list.entries[i]) {
|
||||
let unique = Self::get_unique_entry(&target_list);
|
||||
let unique = Self::get_unique_entry(target_list);
|
||||
intermediate_files.insert(unique.clone(), target_list.entries[i].clone());
|
||||
if ! self.noop { fs::rename(&self.entries[i], &unique).expect("failed to rename file"); }
|
||||
if self.verbose { println!("Moving {} -> {}", self.entries[i], unique); }
|
||||
|
|
@ -137,7 +137,7 @@ impl DirList {
|
|||
// Make sure all destination files are unique in target_list
|
||||
let unique_entries = target_list.entries.iter().map(|x| (x, x)).collect::<HashMap<_, _>>();
|
||||
if target_list.entries.len() != unique_entries.len() {
|
||||
let doubles = self.show_doubles(&target_list);
|
||||
let doubles = self.show_doubles(target_list);
|
||||
let error = format!("ERROR: You're trying to move multiple files to the same name.\n{}", doubles);
|
||||
return Err(error);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue