chore(clippy): Simplify to Path.exists() and remove some more &
authorKlaus Purer <klaus.purer@gmail.com>
Tue, 3 Apr 2018 20:50:36 +0000 (22:50 +0200)
committerKlaus Purer <klaus.purer@gmail.com>
Wed, 4 Apr 2018 21:08:31 +0000 (23:08 +0200)
src/cargo/ops/cargo_new.rs
src/cargo/ops/cargo_rustc/mod.rs

index 2f0e94157aa85c8d91c36994fe5052b06af6efaa..cc2fd73be3545a64f6141944fd4950fd0c264495 100644 (file)
@@ -444,37 +444,40 @@ fn mk(config: &Config, opts: &MkOptions) -> CargoResult<()> {
 
     match vcs {
         VersionControl::Git => {
-            if fs::metadata(&path.join(".git")).is_err() {
+            if !path.join(".git").exists() {
                 GitRepo::init(path, config.cwd())?;
             }
-            let ignore = match fs::metadata(&path.join(".gitignore")) {
-                Ok(_) => format!("\n{}", ignore),
-                _ => ignore,
+            let ignore = if path.join(".gitignore").exists() {
+                format!("\n{}", ignore)
+            } else {
+                ignore
             };
             paths::append(&path.join(".gitignore"), ignore.as_bytes())?;
         }
         VersionControl::Hg => {
-            if fs::metadata(&path.join(".hg")).is_err() {
+            if !path.join(".hg").exists() {
                 HgRepo::init(path, config.cwd())?;
             }
-            let hgignore = match fs::metadata(&path.join(".hgignore")) {
-                Ok(_) => format!("\n{}", hgignore),
-                _ => hgignore,
+            let hgignore = if path.join(".hgignore").exists() {
+                format!("\n{}", hgignore)
+            } else {
+                hgignore
             };
             paths::append(&path.join(".hgignore"), hgignore.as_bytes())?;
         }
         VersionControl::Pijul => {
-            if fs::metadata(&path.join(".pijul")).is_err() {
+            if !path.join(".pijul").exists() {
                 PijulRepo::init(path, config.cwd())?;
             }
-            let ignore = match fs::metadata(&path.join(".ignore")) {
-                Ok(_) => format!("\n{}", ignore),
-                _ => ignore,
+            let ignore = if path.join(".ignore").exists() {
+                format!("\n{}", ignore)
+            } else {
+                ignore
             };
             paths::append(&path.join(".ignore"), ignore.as_bytes())?;
         }
         VersionControl::Fossil => {
-            if fs::metadata(&path.join(".fossil")).is_err() {
+            if path.join(".fossil").exists() {
                 FossilRepo::init(path, config.cwd())?;
             }
         }
index 5f75694824325a40b300a82497b8c0819fd7c3eb..7036cdc675eeaf9fce3ff745ff04789257379b21 100644 (file)
@@ -603,13 +603,13 @@ fn link_targets<'a, 'cfg>(
                 }
             };
             destinations.push(dst.display().to_string());
-            hardlink_or_copy(&src, &dst)?;
+            hardlink_or_copy(src, dst)?;
             if let Some(ref path) = export_dir {
                 if !path.exists() {
                     fs::create_dir_all(path)?;
                 }
 
-                hardlink_or_copy(&src, &path.join(dst.file_name().unwrap()))?;
+                hardlink_or_copy(src, &path.join(dst.file_name().unwrap()))?;
             }
         }