Apply clippy recommendations

This commit is contained in:
Félix Saparelli 2021-04-11 05:44:24 +12:00
parent 6ec02d38ab
commit 05e66784ce
No known key found for this signature in database
GPG Key ID: B948C4BAE44FC474
6 changed files with 13 additions and 25 deletions

View File

@ -28,14 +28,8 @@ impl From<globset::Error> for Error {
impl From<io::Error> for Error {
fn from(err: io::Error) -> Self {
Self::Io(match err.raw_os_error() {
Some(os_err) => match os_err {
7 => {
let msg = "There are so many changed files that the environment variables of the command have been overrun. Try running with --no-meta or --no-environment.";
io::Error::new(io::ErrorKind::Other, msg)
}
_ => err,
},
None => err,
Some(7) => io::Error::new(io::ErrorKind::Other, "There are so many changed files that the environment variables of the command have been overrun. Try running with --no-meta or --no-environment."),
_ => err,
})
}
}

View File

@ -97,7 +97,7 @@ impl Gitignore {
.iter()
.filter(|f| path.starts_with(&f.root))
.collect();
applicable_files.sort_by(|l, r| l.root_len().cmp(&r.root_len()));
applicable_files.sort_by_key(|f| f.root_len());
// TODO: add user gitignores

View File

@ -103,7 +103,7 @@ impl Ignore {
.iter()
.filter(|f| path.starts_with(&f.root))
.collect();
applicable_files.sort_by(|l, r| l.root_len().cmp(&r.root_len()));
applicable_files.sort_by_key(|f| f.root_len());
// TODO: add user ignores

View File

@ -9,7 +9,7 @@
//!
//! [watchexec]: https://github.com/watchexec/watchexec
#![warn(clippy::option_unwrap_used, clippy::result_unwrap_used)]
#![warn(clippy::unwrap_used)]
#[macro_use]
extern crate derive_builder;

View File

@ -118,15 +118,13 @@ mod imp {
unsafe {
command.pre_exec(|| setsid().map_err(from_nix_error).map(|_| ()));
}
command.spawn().and_then(|p| {
Ok(Self {
pgid: p
.id()
.try_into()
.expect("u32 -> i32 failed in process::new"),
lock: Mutex::new(false),
cvar: Condvar::new(),
})
command.spawn().map(|p| Self {
pgid: p
.id()
.try_into()
.expect("u32 -> i32 failed in process::new"),
lock: Mutex::new(false),
cvar: Condvar::new(),
})
}

View File

@ -56,10 +56,6 @@ impl Watcher {
}
pub fn is_polling(&self) -> bool {
if let WatcherImpl::Poll(_) = self.watcher_impl {
true
} else {
false
}
matches!(self.watcher_impl, WatcherImpl::Poll(_))
}
}