Skip to content

Commit 0c28175

Browse files
committed
use PathBuf in cargo metadata
I don't remember why we've used strings in the first place here, but I think that historically there just weren't Serialize impls for `Path`s!
1 parent 497f426 commit 0c28175

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

src/cargo/ops/cargo_output_metadata.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
use std::collections::HashMap;
2+
use std::path::PathBuf;
23

34
use serde::ser;
45
use serde::Serialize;
@@ -41,9 +42,9 @@ fn metadata_no_deps(ws: &Workspace<'_>, _opt: &OutputMetadataOptions) -> CargoRe
4142
packages: ws.members().cloned().collect(),
4243
workspace_members: ws.members().map(|pkg| pkg.package_id()).collect(),
4344
resolve: None,
44-
target_directory: ws.target_dir().display().to_string(),
45+
target_directory: ws.target_dir().clone().into_path_unlocked(),
4546
version: VERSION,
46-
workspace_root: ws.root().display().to_string(),
47+
workspace_root: ws.root().to_path_buf(),
4748
})
4849
}
4950

@@ -69,9 +70,9 @@ fn metadata_full(ws: &Workspace<'_>, opt: &OutputMetadataOptions) -> CargoResult
6970
resolve: (packages, resolve),
7071
root: ws.current_opt().map(|pkg| pkg.package_id()),
7172
}),
72-
target_directory: ws.target_dir().display().to_string(),
73+
target_directory: ws.target_dir().clone().into_path_unlocked(),
7374
version: VERSION,
74-
workspace_root: ws.root().display().to_string(),
75+
workspace_root: ws.root().to_path_buf(),
7576
})
7677
}
7778

@@ -80,9 +81,9 @@ pub struct ExportInfo {
8081
packages: Vec<Package>,
8182
workspace_members: Vec<PackageId>,
8283
resolve: Option<MetadataResolve>,
83-
target_directory: String,
84+
target_directory: PathBuf,
8485
version: u32,
85-
workspace_root: String,
86+
workspace_root: PathBuf,
8687
}
8788

8889
/// Newtype wrapper to provide a custom `Serialize` implementation.

0 commit comments

Comments
 (0)