From 38f1ce633d78289c71e0f860d82fda5a62db8f7b Mon Sep 17 00:00:00 2001 From: Aaron Wood Date: Sun, 20 Sep 2020 12:06:12 -0700 Subject: Add rustdoc for ProjectJson methods --- crates/project_model/src/project_json.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'crates/project_model') diff --git a/crates/project_model/src/project_json.rs b/crates/project_model/src/project_json.rs index 1ab1221cb..a6895ecdd 100644 --- a/crates/project_model/src/project_json.rs +++ b/crates/project_model/src/project_json.rs @@ -34,6 +34,13 @@ pub struct Crate { } impl ProjectJson { + /// Create a new ProjectJson instance. + /// + /// # Arguments + /// + /// * `base` - The path to the workspace root (i.e. the folder containing `rust-project.json`) + /// * `data` - The parsed contents of `rust-project.json`, or project json that's passed via + /// configuration. pub fn new(base: &AbsPath, data: ProjectJsonData) -> ProjectJson { ProjectJson { sysroot_src: data.sysroot_src.map(|it| base.join(it)), @@ -85,12 +92,15 @@ impl ProjectJson { .collect::>(), } } + /// 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 + '_ { 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 } -- cgit v1.2.3