mirror of
https://github.com/BurntSushi/ripgrep.git
synced 2025-07-31 04:02:00 -07:00
ignore: polish
Like previous commits, we do a bit of polishing and bring the style up to my current practice.
This commit is contained in:
@@ -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();
|
||||
}
|
||||
|
Reference in New Issue
Block a user