From 15df372bd17eb11137d4ffc745bfdb3cdbabed6b Mon Sep 17 00:00:00 2001 From: Thomas Voss Date: Mon, 7 Aug 2023 01:06:01 +0200 Subject: Add a helper ‘disp()’ function MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/main.rs b/src/main.rs index c7ffa55..c391320 100644 --- a/src/main.rs +++ b/src/main.rs @@ -7,7 +7,7 @@ use std::{ hash::{Hash, Hasher}, io::{self, BufWriter, Read, Write}, iter, - path::{Component, Path, PathBuf}, + path::{Component, Display, Path, PathBuf}, process::{self, Command, Stdio}, }; @@ -145,7 +145,7 @@ fn work() -> Result<(), io::Error> { if flags.dryrun { for (s, _, d) in ps { - println!("{} -> {}", s.as_path().display(), d.as_path().display()); + println!("{} -> {}", disp(&s), disp(&d)); } } else { for (s, t, _) in ps.iter() { @@ -373,7 +373,7 @@ fn normalize_path(path: &Path) -> PathBuf { fn move_path(flags: &Flags, from: &PathBuf, to: &PathBuf) { if flags.verbose { - println!("{} -> {}", from.as_path().display(), to.as_path().display()); + println!("{} -> {}", disp(&from), disp(&to)); } if !flags.dryrun { @@ -401,3 +401,7 @@ fn copy_and_remove_file_or_dir<'a>( fn is_terminal(flags: &Flags, b: &u8) -> bool { *b == (b'\0' + b'\n' * !flags.nul as u8) } + +fn disp(pb: &PathBuf) -> Display { + pb.as_path().display() +} -- cgit v1.2.3