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") .long("exts")
.takes_value(true)) .takes_value(true))
.arg(Arg::with_name("path") .arg(Arg::with_name("path")
.help("Watch a specific directory") .help("Watch a specific directory")
.short("w") .short("w")
.long("watch") .long("watch")
.number_of_values(1) .number_of_values(1)
.multiple(true) .multiple(true)
.takes_value(true)) .takes_value(true))
.arg(Arg::with_name("clear") .arg(Arg::with_name("clear")
.help("Clear screen before executing command") .help("Clear screen before executing command")
.short("c") .short("c")

View File

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

View File

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

View File

@ -22,12 +22,16 @@ enum WatcherImpl {
} }
impl Watcher { 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; use notify::Watcher;
let imp = if poll { let imp = if poll {
let mut watcher = try!(PollWatcher::with_delay_ms(tx, interval_ms)); 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)); try!(watcher.watch(path, RecursiveMode::Recursive));
debug!("Watching {:?}", path); debug!("Watching {:?}", path);
} }
@ -35,7 +39,7 @@ impl Watcher {
WatcherImpl::Poll(watcher) WatcherImpl::Poll(watcher)
} else { } else {
let mut watcher = try!(raw_watcher(tx)); let mut watcher = try!(raw_watcher(tx));
for ref path in paths { for path in paths {
try!(watcher.watch(path, RecursiveMode::Recursive)); try!(watcher.watch(path, RecursiveMode::Recursive));
debug!("Watching {:?}", path); debug!("Watching {:?}", path);
} }