rustfmt & clippy fixes

This commit is contained in:
Matt Green 2017-02-04 16:26:59 -05:00
parent e16a6b3a24
commit 125e7eb7c8
4 changed files with 21 additions and 15 deletions

View File

@ -46,12 +46,12 @@ pub fn get_args() -> Args {
.long("exts")
.takes_value(true))
.arg(Arg::with_name("path")
.help("Watch a specific directory")
.short("w")
.long("watch")
.number_of_values(1)
.multiple(true)
.takes_value(true))
.help("Watch a specific directory")
.short("w")
.long("watch")
.number_of_values(1)
.multiple(true)
.takes_value(true))
.arg(Arg::with_name("clear")
.help("Clear screen before executing command")
.short("c")

View File

@ -41,7 +41,7 @@ enum MatchResult {
None,
}
pub fn load(paths: &Vec<PathBuf>) -> Gitignore {
pub fn load(paths: &[PathBuf]) -> Gitignore {
let mut files = vec![];
let mut checked_dirs = HashSet::new();

View File

@ -80,16 +80,18 @@ fn main() {
let paths: Vec<PathBuf> = args.paths
.iter()
.map(|p| Path::new(&p)
.canonicalize()
.expect(&format!("unable to canonicalize \"{}\"", &p))
.to_owned())
.map(|p| {
Path::new(&p)
.canonicalize()
.expect(&format!("unable to canonicalize \"{}\"", &p))
.to_owned()
})
.collect();
let gitignore = if !args.no_vcs_ignore {
gitignore::load(&paths)
} else {
gitignore::load(&vec![])
gitignore::load(&[])
};
let filter = NotificationFilter::new(args.filters, args.ignores, gitignore)

View File

@ -22,12 +22,16 @@ enum WatcherImpl {
}
impl Watcher {
pub fn new(tx: Sender<Event>, paths: &Vec<PathBuf>, poll: bool, interval_ms: u32) -> Result<Watcher, Error> {
pub fn new(tx: Sender<Event>,
paths: &[PathBuf],
poll: bool,
interval_ms: u32)
-> Result<Watcher, Error> {
use notify::Watcher;
let imp = if poll {
let mut watcher = try!(PollWatcher::with_delay_ms(tx, interval_ms));
for ref path in paths {
for path in paths {
try!(watcher.watch(path, RecursiveMode::Recursive));
debug!("Watching {:?}", path);
}
@ -35,7 +39,7 @@ impl Watcher {
WatcherImpl::Poll(watcher)
} else {
let mut watcher = try!(raw_watcher(tx));
for ref path in paths {
for path in paths {
try!(watcher.watch(path, RecursiveMode::Recursive));
debug!("Watching {:?}", path);
}