aboutsummaryrefslogtreecommitdiff
path: root/src/main.rs
diff options
context:
space:
mode:
authorThomas Voss <mail@thomasvoss.com> 2023-08-07 01:06:01 +0200
committerThomas Voss <mail@thomasvoss.com> 2023-08-07 01:06:01 +0200
commit15df372bd17eb11137d4ffc745bfdb3cdbabed6b (patch)
tree1ab77007941b8e1e2188c3cab17b23cbc3db1a86 /src/main.rs
parentddaaca5aaad4b8841cc04875b2cd0c1ab9ec0351 (diff)
Add a helper ‘disp()’ function
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs10
1 files 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()
+}