aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_project_model
diff options
context:
space:
mode:
authorEmil Lauridsen <[email protected]>2020-01-10 21:41:52 +0000
committerEmil Lauridsen <[email protected]>2020-01-10 21:41:52 +0000
commitd6da18e99d2fb4e67e3bc7503059282b5e14bd13 (patch)
tree712cdb37b25f553c5739f319a849414de480cff4 /crates/ra_project_model
parent1d1eea217d5b674e6cad77704f912a3a76505d70 (diff)
Address nit
Diffstat (limited to 'crates/ra_project_model')
-rw-r--r--crates/ra_project_model/src/cargo_workspace.rs6
-rw-r--r--crates/ra_project_model/src/lib.rs2
2 files changed, 6 insertions, 2 deletions
diff --git a/crates/ra_project_model/src/cargo_workspace.rs b/crates/ra_project_model/src/cargo_workspace.rs
index 18c2f11b7..1832c101f 100644
--- a/crates/ra_project_model/src/cargo_workspace.rs
+++ b/crates/ra_project_model/src/cargo_workspace.rs
@@ -21,7 +21,7 @@ use crate::Result;
21pub struct CargoWorkspace { 21pub struct CargoWorkspace {
22 packages: Arena<Package, PackageData>, 22 packages: Arena<Package, PackageData>,
23 targets: Arena<Target, TargetData>, 23 targets: Arena<Target, TargetData>,
24 pub workspace_root: PathBuf, 24 workspace_root: PathBuf,
25} 25}
26 26
27#[derive(Deserialize, Clone, Debug, PartialEq, Eq)] 27#[derive(Deserialize, Clone, Debug, PartialEq, Eq)]
@@ -225,4 +225,8 @@ impl CargoWorkspace {
225 pub fn target_by_root(&self, root: &Path) -> Option<Target> { 225 pub fn target_by_root(&self, root: &Path) -> Option<Target> {
226 self.packages().filter_map(|pkg| pkg.targets(self).find(|it| it.root(self) == root)).next() 226 self.packages().filter_map(|pkg| pkg.targets(self).find(|it| it.root(self) == root)).next()
227 } 227 }
228
229 pub fn workspace_root(&self) -> &Path {
230 &self.workspace_root
231 }
228} 232}
diff --git a/crates/ra_project_model/src/lib.rs b/crates/ra_project_model/src/lib.rs
index b7f6a9b57..6a104e6f2 100644
--- a/crates/ra_project_model/src/lib.rs
+++ b/crates/ra_project_model/src/lib.rs
@@ -333,7 +333,7 @@ impl ProjectWorkspace {
333 pub fn workspace_root_for(&self, path: &Path) -> Option<&Path> { 333 pub fn workspace_root_for(&self, path: &Path) -> Option<&Path> {
334 match self { 334 match self {
335 ProjectWorkspace::Cargo { cargo, .. } => { 335 ProjectWorkspace::Cargo { cargo, .. } => {
336 Some(cargo.workspace_root.as_ref()).filter(|root| path.starts_with(root)) 336 Some(cargo.workspace_root()).filter(|root| path.starts_with(root))
337 } 337 }
338 ProjectWorkspace::Json { project: JsonProject { roots, .. } } => roots 338 ProjectWorkspace::Json { project: JsonProject { roots, .. } } => roots
339 .iter() 339 .iter()