Skip to content

Commit 38f1ce6

Browse files
committed
Add rustdoc for ProjectJson methods
1 parent 2fbb09a commit 38f1ce6

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

crates/project_model/src/project_json.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,13 @@ pub struct Crate {
3434
}
3535

3636
impl ProjectJson {
37+
/// Create a new ProjectJson instance.
38+
///
39+
/// # Arguments
40+
///
41+
/// * `base` - The path to the workspace root (i.e. the folder containing `rust-project.json`)
42+
/// * `data` - The parsed contents of `rust-project.json`, or project json that's passed via
43+
/// configuration.
3744
pub fn new(base: &AbsPath, data: ProjectJsonData) -> ProjectJson {
3845
ProjectJson {
3946
sysroot_src: data.sysroot_src.map(|it| base.join(it)),
@@ -85,12 +92,15 @@ impl ProjectJson {
8592
.collect::<Vec<_>>(),
8693
}
8794
}
95+
/// Returns the number of crates in the project.
8896
pub fn n_crates(&self) -> usize {
8997
self.crates.len()
9098
}
99+
/// Returns an iterator over the crates in the project.
91100
pub fn crates(&self) -> impl Iterator<Item = (CrateId, &Crate)> + '_ {
92101
self.crates.iter().enumerate().map(|(idx, krate)| (CrateId(idx as u32), krate))
93102
}
103+
/// Returns the path to the project's root folder.
94104
pub fn path(&self) -> &AbsPath {
95105
&self.project_root
96106
}

0 commit comments

Comments
 (0)