Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 6f67f07

Browse files
refactor: simplify manifest_path option checks
1 parent aef8e93 commit 6f67f07

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/cargo-fmt/main.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,7 @@ fn execute() -> i32 {
101101

102102
let strategy = CargoFmtStrategy::from_opts(&opts);
103103

104-
if opts.manifest_path.is_some() {
105-
let specified_manifest_path = opts.manifest_path.unwrap();
104+
if let Some(specified_manifest_path) = opts.manifest_path {
106105
if !specified_manifest_path.ends_with("Cargo.toml") {
107106
print_usage_to_stderr("the manifest-path must be a path to a Cargo.toml file");
108107
return FAILURE;
@@ -284,9 +283,11 @@ fn get_targets_root_only(
284283
) -> Result<(), io::Error> {
285284
let metadata = get_cargo_metadata(manifest_path, false)?;
286285
let workspace_root_path = PathBuf::from(&metadata.workspace_root).canonicalize()?;
287-
let (in_workspace_root, current_dir_manifest) = if manifest_path.is_some() {
288-
let target_manifest = manifest_path.unwrap().canonicalize()?;
289-
(workspace_root_path == target_manifest, target_manifest)
286+
let (in_workspace_root, current_dir_manifest) = if let Some(target_manifest) = manifest_path {
287+
(
288+
workspace_root_path == target_manifest,
289+
target_manifest.canonicalize()?,
290+
)
290291
} else {
291292
let current_dir = env::current_dir()?.canonicalize()?;
292293
(

0 commit comments

Comments
 (0)