diff --git a/src/action.rs b/src/action.rs index c493fd0..af879f1 100644 --- a/src/action.rs +++ b/src/action.rs @@ -72,7 +72,12 @@ pub enum Action { } impl Action { - pub fn rename(new_name: S) -> Self where S: AsRef { - Self::Rename {new_name: new_name.as_ref().to_owned()} + pub fn rename(new_name: S) -> Self + where + S: AsRef, + { + Self::Rename { + new_name: new_name.as_ref().to_owned(), + } } } diff --git a/src/main.rs b/src/main.rs index 585af87..75fe835 100644 --- a/src/main.rs +++ b/src/main.rs @@ -355,28 +355,29 @@ fn main() -> Result<(), String> { .expect("path points to file")] } } - OldVersionPolicy::Archive => { - //TODO avoid lossy match - present_file_names - .iter() - .filter(|file| file_matcher.matches(file)) - .map(|file| { - FileAction::new( - file, - Action::rename(format!( - "{}{}", - file.to_string_lossy(), - file.to_string_lossy().chars().last().unwrap_or('1') - )), - ) - .expect("path points to file") - }) - .chain(once(add_action)) - .collect() - }, + OldVersionPolicy::Archive => present_file_names + .iter() + .filter(|file| file_matcher.matches(file)) + .map(|file| { + FileAction::new( + file, + Action::rename( + osf!(file) + + file + .to_string_lossy() + .chars() + .last() + .unwrap_or('1') + .to_string(), + ), + ) + .expect("path points to file") + }) + .chain(once(add_action)) + .collect(), OldVersionPolicy::Delete => { - //TODO avoid lossy match - let mut actions = present_file_names.iter() + let mut actions = present_file_names + .iter() .filter(|file| file_matcher.matches(file)) .map(|file| { //special case -> file has the same name as current file, then we just need to replace it