Better fedora handling

This commit is contained in:
Roey Darwish Dror
2019-09-28 20:26:03 +03:00
parent fb38b792a4
commit 48e694cdd5
2 changed files with 18 additions and 10 deletions

View File

@@ -38,9 +38,12 @@ where
fn require(self) -> Result<Self, Error>;
}
impl PathExt for PathBuf {
impl<T> PathExt for T
where
T: AsRef<Path>,
{
fn if_exists(self) -> Option<Self> {
if self.exists() {
if self.as_ref().exists() {
Some(self)
} else {
None
@@ -48,11 +51,11 @@ impl PathExt for PathBuf {
}
fn is_descendant_of(&self, ancestor: &Path) -> bool {
self.iter().zip(ancestor.iter()).all(|(a, b)| a == b)
self.as_ref().iter().zip(ancestor.iter()).all(|(a, b)| a == b)
}
fn require(self) -> Result<Self, Error> {
if self.exists() {
if self.as_ref().exists() {
Ok(self)
} else {
Err(ErrorKind::SkipStep.into())