aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/checker.rs4
-rw-r--r--src/finder.rs5
2 files changed, 5 insertions, 4 deletions
diff --git a/src/checker.rs b/src/checker.rs
index 62b78a2..0e92c6a 100644
--- a/src/checker.rs
+++ b/src/checker.rs
@@ -1,7 +1,5 @@
use crate::finder::Checker;
#[cfg(unix)]
-use libc;
-#[cfg(unix)]
use std::ffi::CString;
use std::fs;
#[cfg(unix)]
@@ -20,7 +18,7 @@ impl Checker for ExecutableChecker {
#[cfg(unix)]
fn is_valid(&self, path: &Path) -> bool {
CString::new(path.as_os_str().as_bytes())
- .and_then(|c| Ok(unsafe { libc::access(c.as_ptr(), libc::X_OK) == 0 }))
+ .map(|c| unsafe { libc::access(c.as_ptr(), libc::X_OK) == 0 })
.unwrap_or(false)
}
diff --git a/src/finder.rs b/src/finder.rs
index 43b659d..9b64294 100644
--- a/src/finder.rs
+++ b/src/finder.rs
@@ -94,6 +94,9 @@ impl Finder {
T: AsRef<OsStr>,
{
let p = paths.ok_or(Error::CannotFindBinaryPath)?;
+ // Collect needs to happen in order to not have to
+ // change the API to borrow on `paths`.
+ #[allow(clippy::needless_collect)]
let paths: Vec<_> = env::split_paths(&p).collect();
let matching_re = paths
@@ -169,7 +172,7 @@ impl Finder {
})
// PATHEXT not being set or not being a proper Unicode string is exceedingly
// improbable and would probably break Windows badly. Still, don't crash:
- .unwrap_or(vec![]);
+ .unwrap_or_default();
}
paths