Skip to content

Commit

Permalink
Add target_directory path to CargoWorkspace
Browse files Browse the repository at this point in the history
  • Loading branch information
Ddystopia committed May 2, 2023
1 parent a48e0e1 commit fc888b5
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion crates/project-model/src/cargo_workspace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ pub struct CargoWorkspace {
packages: Arena<PackageData>,
targets: Arena<TargetData>,
workspace_root: AbsPathBuf,
target_directory: AbsPathBuf,
}

impl ops::Index<Package> for CargoWorkspace {
Expand Down Expand Up @@ -414,7 +415,10 @@ impl CargoWorkspace {
let workspace_root =
AbsPathBuf::assert(PathBuf::from(meta.workspace_root.into_os_string()));

CargoWorkspace { packages, targets, workspace_root }
let target_directory =
AbsPathBuf::assert(PathBuf::from(meta.target_directory.into_os_string()));

CargoWorkspace { packages, targets, workspace_root, target_directory }
}

pub fn packages(&self) -> impl Iterator<Item = Package> + ExactSizeIterator + '_ {
Expand All @@ -432,6 +436,10 @@ impl CargoWorkspace {
&self.workspace_root
}

pub fn target_directory(&self) -> &AbsPath {
&self.target_directory
}

pub fn package_flag(&self, package: &PackageData) -> String {
if self.is_unique(&package.name) {
package.name.clone()
Expand Down

0 comments on commit fc888b5

Please sign in to comment.