This commit is contained in:
Lukas Wirth 2022-09-19 17:31:08 +02:00
parent d9f5709609
commit a6c067c06d
14 changed files with 89 additions and 88 deletions

View file

@ -110,14 +110,17 @@ impl ProjectJson {
.collect::<Vec<_>>(),
}
}
/// Returns the number of crates in the project.
pub fn n_crates(&self) -> usize {
self.crates.len()
}
/// Returns an iterator over the crates in the project.
pub fn crates(&self) -> impl Iterator<Item = (CrateId, &Crate)> + '_ {
self.crates.iter().enumerate().map(|(idx, krate)| (CrateId(idx as u32), krate))
}
/// Returns the path to the project's root folder.
pub fn path(&self) -> &AbsPath {
&self.project_root