diff --git a/src/util.rs b/src/util.rs index a6f4b80..5a7c0de 100644 --- a/src/util.rs +++ b/src/util.rs @@ -39,21 +39,21 @@ pub fn ensure_samply_profile(cargo_toml: &Path) -> error::Result<()> { .and_then(|p| p.get("samply")); if profile_samply.is_none() { - let mut f = OpenOptions::new().append(true).open(&cargo_toml).unwrap(); - f.write(SAMPLY_PROFILE.as_bytes()).path_ctx(&cargo_toml)?; + let mut f = OpenOptions::new().append(true).open(cargo_toml).unwrap(); + f.write(SAMPLY_PROFILE.as_bytes()).path_ctx(cargo_toml)?; info!("'samply' profile was added to 'Cargo.toml'"); } Ok(()) } pub fn guess_bin(cargo_toml: &Path) -> error::Result { - let manifest = cargo_toml::Manifest::from_path(&cargo_toml)?; + let manifest = cargo_toml::Manifest::from_path(cargo_toml)?; let default_run = manifest.package.and_then(|p| p.default_run); if let Some(bin) = default_run { - return Ok(bin); + Ok(bin) } else if manifest.bin.len() == 1 { return Ok(manifest.bin.first().unwrap().name.clone().unwrap()); - } else if manifest.bin.len() == 0 { + } else if manifest.bin.is_empty() { return Err(error::Error::NoBinaryFound); } else { return Err(error::Error::BinaryToRunNotDetermined); diff --git a/tests/cli_tests.rs b/tests/cli_tests.rs index 7abfcbb..084bd39 100644 --- a/tests/cli_tests.rs +++ b/tests/cli_tests.rs @@ -13,7 +13,8 @@ fn trycmd() { .register_bin("cargo", trycmd::schema::Bin::Path(which("cargo").unwrap())); for pth in cargo_bins.iter().filter(|pth| { - !pth.extension().is_some_and(|pth| pth == "exe") && pth.file_name().is_some_and(|p| p !="cargo-samply") + !pth.extension().is_some_and(|pth| pth == "exe") + && pth.file_name().is_some_and(|p| p != "cargo-samply") }) { println!("{}", pth.file_name().unwrap().to_string_lossy()); t = t.register_bin(