Skip to content

Commit

Permalink
refactor: Fix clippy warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
sgryjp committed Nov 18, 2023
1 parent 851ada1 commit 8ae6041
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
4 changes: 3 additions & 1 deletion src/fsutil.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@ use std::cmp;
use std::io::{self, Write};
use std::path::{Path, PathBuf};

pub type Callback = dyn Fn(&Path, &Path, &io::Error);

pub fn move_files(
actions: &[Action],
dry_run: bool,
interactive: bool,
verbose: bool,
on_error: Option<&dyn Fn(&Path, &Path, &io::Error)>,
on_error: Option<&Callback>,
) -> i32 {
let mut num_errors = 0;

Expand Down
4 changes: 2 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ pub fn print_error<S: AsRef<str>>(msg: S) {
}

let msg = msg.as_ref();
if let Err(_) = do_print(msg) {
if do_print(msg).is_err() {
eprintln!("error: {}", msg);
}
}
Expand Down Expand Up @@ -139,7 +139,7 @@ pub fn try_main(args: &[OsString]) -> Result<(), String> {
let config = parse_args(args);

// Collect paths of the files to move with their destination
let actions = matches_to_actions(config.src_ptn.as_str(), config.dest_ptn.as_str());
let actions = matches_to_actions(&config.src_ptn, &config.dest_ptn);

let actions = sort_actions(&actions)?;

Expand Down
2 changes: 1 addition & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use std::ffi::OsString;
use pmv::{print_error, try_main};

fn main() -> Result<(), ()> {
let args: Vec<OsString> = env::args_os().into_iter().collect();
let args: Vec<OsString> = env::args_os().collect();

if let Err(err) = try_main(&args[..]) {
print_error(err);
Expand Down

0 comments on commit 8ae6041

Please sign in to comment.