summaryrefslogtreecommitdiffstats
path: root/vendor/ignore/examples
diff options
context:
space:
mode:
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();
-}