diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2020-08-25 17:41:10 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2020-08-25 17:41:10 +0100 |
commit | 6141e2706ae73450eea317b6326307b9c54f41b6 (patch) | |
tree | 25152062452c88a34bd9e4351f33ac8aed6b17e4 /crates/project_model/src/project_json.rs | |
parent | 13fd8846b4bdf214cce467b19fefe44ca518a849 (diff) | |
parent | 9786a8f2d4cf0a2454919c75426bd3a847615a1c (diff) |
Merge #5882
5882: Don't expose indexing details
r=matklad a=matklad
bors r+
🤖
Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/project_model/src/project_json.rs')
-rw-r--r-- | crates/project_model/src/project_json.rs | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/crates/project_model/src/project_json.rs b/crates/project_model/src/project_json.rs index 060ea5b7d..ae14e5126 100644 --- a/crates/project_model/src/project_json.rs +++ b/crates/project_model/src/project_json.rs | |||
@@ -12,7 +12,7 @@ use crate::cfg_flag::CfgFlag; | |||
12 | /// Roots and crates that compose this Rust project. | 12 | /// Roots and crates that compose this Rust project. |
13 | #[derive(Clone, Debug, Eq, PartialEq)] | 13 | #[derive(Clone, Debug, Eq, PartialEq)] |
14 | pub struct ProjectJson { | 14 | pub struct ProjectJson { |
15 | pub(crate) crates: Vec<Crate>, | 15 | crates: Vec<Crate>, |
16 | } | 16 | } |
17 | 17 | ||
18 | /// A crate points to the root module of a crate and lists the dependencies of the crate. This is | 18 | /// A crate points to the root module of a crate and lists the dependencies of the crate. This is |
@@ -79,6 +79,12 @@ impl ProjectJson { | |||
79 | .collect::<Vec<_>>(), | 79 | .collect::<Vec<_>>(), |
80 | } | 80 | } |
81 | } | 81 | } |
82 | pub fn n_crates(&self) -> usize { | ||
83 | self.crates.len() | ||
84 | } | ||
85 | pub fn crates(&self) -> impl Iterator<Item = (CrateId, &Crate)> + '_ { | ||
86 | self.crates.iter().enumerate().map(|(idx, krate)| (CrateId(idx as u32), krate)) | ||
87 | } | ||
82 | } | 88 | } |
83 | 89 | ||
84 | #[derive(Deserialize)] | 90 | #[derive(Deserialize)] |