aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_project_model/src
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2019-08-06 09:54:51 +0100
committerAleksey Kladov <[email protected]>2019-08-06 09:57:16 +0100
commitd751bd08bfa36bd8abdcbb4fa466022720094b7d (patch)
treef514f0f74b4da150dc6086438879731a13ef74e1 /crates/ra_project_model/src
parent0e4a542cfb366898a4d53701c50ae4d1732d7c53 (diff)
cleanup
Diffstat (limited to 'crates/ra_project_model/src')
-rw-r--r--crates/ra_project_model/src/cargo_workspace.rs2
-rw-r--r--crates/ra_project_model/src/lib.rs9
-rw-r--r--crates/ra_project_model/src/sysroot.rs2
3 files changed, 7 insertions, 6 deletions
diff --git a/crates/ra_project_model/src/cargo_workspace.rs b/crates/ra_project_model/src/cargo_workspace.rs
index 2b06e9e37..712d8818f 100644
--- a/crates/ra_project_model/src/cargo_workspace.rs
+++ b/crates/ra_project_model/src/cargo_workspace.rs
@@ -167,7 +167,7 @@ impl CargoWorkspace {
167 Ok(CargoWorkspace { packages, targets, workspace_root: meta.workspace_root }) 167 Ok(CargoWorkspace { packages, targets, workspace_root: meta.workspace_root })
168 } 168 }
169 169
170 pub fn packages<'a>(&'a self) -> impl Iterator<Item = Package> + 'a { 170 pub fn packages<'a>(&'a self) -> impl Iterator<Item = Package> + ExactSizeIterator + 'a {
171 self.packages.iter().map(|(id, _pkg)| id) 171 self.packages.iter().map(|(id, _pkg)| id)
172 } 172 }
173 173
diff --git a/crates/ra_project_model/src/lib.rs b/crates/ra_project_model/src/lib.rs
index 647a1f365..8e81396d4 100644
--- a/crates/ra_project_model/src/lib.rs
+++ b/crates/ra_project_model/src/lib.rs
@@ -112,8 +112,7 @@ impl ProjectWorkspace {
112 roots 112 roots
113 } 113 }
114 ProjectWorkspace::Cargo { cargo, sysroot } => { 114 ProjectWorkspace::Cargo { cargo, sysroot } => {
115 let mut roots = 115 let mut roots = Vec::with_capacity(cargo.packages().len() + sysroot.crates().len());
116 Vec::with_capacity(cargo.packages().count() + sysroot.crates().count());
117 for pkg in cargo.packages() { 116 for pkg in cargo.packages() {
118 let root = pkg.root(&cargo).to_path_buf(); 117 let root = pkg.root(&cargo).to_path_buf();
119 let member = pkg.is_member(&cargo); 118 let member = pkg.is_member(&cargo);
@@ -127,10 +126,12 @@ impl ProjectWorkspace {
127 } 126 }
128 } 127 }
129 128
130 pub fn count(&self) -> usize { 129 pub fn n_packages(&self) -> usize {
131 match self { 130 match self {
132 ProjectWorkspace::Json { project } => project.crates.len(), 131 ProjectWorkspace::Json { project } => project.crates.len(),
133 ProjectWorkspace::Cargo { cargo, .. } => cargo.packages().count(), 132 ProjectWorkspace::Cargo { cargo, sysroot } => {
133 cargo.packages().len() + sysroot.crates().len()
134 }
134 } 135 }
135 } 136 }
136 137
diff --git a/crates/ra_project_model/src/sysroot.rs b/crates/ra_project_model/src/sysroot.rs
index 4f6e880dd..3f34d51cc 100644
--- a/crates/ra_project_model/src/sysroot.rs
+++ b/crates/ra_project_model/src/sysroot.rs
@@ -28,7 +28,7 @@ impl Sysroot {
28 self.by_name("std") 28 self.by_name("std")
29 } 29 }
30 30
31 pub fn crates<'a>(&'a self) -> impl Iterator<Item = SysrootCrate> + 'a { 31 pub fn crates<'a>(&'a self) -> impl Iterator<Item = SysrootCrate> + ExactSizeIterator + 'a {
32 self.crates.iter().map(|(id, _data)| id) 32 self.crates.iter().map(|(id, _data)| id)
33 } 33 }
34 34