aboutsummaryrefslogtreecommitdiff
path: root/crates/project_model/src/project_json.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/project_model/src/project_json.rs')
-rw-r--r--crates/project_model/src/project_json.rs8
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)]
14pub struct ProjectJson { 14pub 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)]