summaryrefslogtreecommitdiffstats
path: root/vendor/ignore/examples
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-19 09:26:03 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-19 09:26:03 +0000
commit9918693037dce8aa4bb6f08741b6812923486c18 (patch)
tree21d2b40bec7e6a7ea664acee056eb3d08e15a1cf /vendor/ignore/examples
parentReleasing progress-linux version 1.75.0+dfsg1-5~progress7.99u1. (diff)
downloadrustc-9918693037dce8aa4bb6f08741b6812923486c18.tar.xz
rustc-9918693037dce8aa4bb6f08741b6812923486c18.zip
Merging upstream version 1.76.0+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/ignore/examples')
-rw-r--r--vendor/ignore/examples/walk.rs28
1 files changed, 6 insertions, 22 deletions
diff --git a/vendor/ignore/examples/walk.rs b/vendor/ignore/examples/walk.rs
index e064478c5..5bbd10f2b 100644
--- a/vendor/ignore/examples/walk.rs
+++ b/vendor/ignore/examples/walk.rs
@@ -1,10 +1,6 @@
-use std::env;
-use std::io::{self, Write};
-use std::path::Path;
-use std::thread;
+use std::{env, io::Write, path::Path};
-use ignore::WalkBuilder;
-use walkdir::WalkDir;
+use {bstr::ByteVec, ignore::WalkBuilder, walkdir::WalkDir};
fn main() {
let mut path = env::args().nth(1).unwrap();
@@ -19,10 +15,11 @@ fn main() {
simple = true;
}
- let stdout_thread = thread::spawn(move || {
- let mut stdout = io::BufWriter::new(io::stdout());
+ let stdout_thread = std::thread::spawn(move || {
+ let mut stdout = std::io::BufWriter::new(std::io::stdout());
for dent in rx {
- write_path(&mut stdout, dent.path());
+ stdout.write(&*Vec::from_path_lossy(dent.path())).unwrap();
+ stdout.write(b"\n").unwrap();
}
});
@@ -65,16 +62,3 @@ impl DirEntry {
}
}
}
-
-#[cfg(unix)]
-fn write_path<W: Write>(mut wtr: W, path: &Path) {
- use std::os::unix::ffi::OsStrExt;
- wtr.write(path.as_os_str().as_bytes()).unwrap();
- wtr.write(b"\n").unwrap();
-}
-
-#[cfg(not(unix))]
-fn write_path<W: Write>(mut wtr: W, path: &Path) {
- wtr.write(path.to_string_lossy().as_bytes()).unwrap();
- wtr.write(b"\n").unwrap();
-}