mirror of
https://github.com/rust-lang/rust.git
synced 2025-06-04 19:29:07 +00:00
Add rustdoc for ProjectJson methods
This commit is contained in:
parent
2fbb09a73f
commit
38f1ce633d
@ -34,6 +34,13 @@ pub struct Crate {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl ProjectJson {
|
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 {
|
pub fn new(base: &AbsPath, data: ProjectJsonData) -> ProjectJson {
|
||||||
ProjectJson {
|
ProjectJson {
|
||||||
sysroot_src: data.sysroot_src.map(|it| base.join(it)),
|
sysroot_src: data.sysroot_src.map(|it| base.join(it)),
|
||||||
@ -85,12 +92,15 @@ impl ProjectJson {
|
|||||||
.collect::<Vec<_>>(),
|
.collect::<Vec<_>>(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/// Returns the number of crates in the project.
|
||||||
pub fn n_crates(&self) -> usize {
|
pub fn n_crates(&self) -> usize {
|
||||||
self.crates.len()
|
self.crates.len()
|
||||||
}
|
}
|
||||||
|
/// Returns an iterator over the crates in the project.
|
||||||
pub fn crates(&self) -> impl Iterator<Item = (CrateId, &Crate)> + '_ {
|
pub fn crates(&self) -> impl Iterator<Item = (CrateId, &Crate)> + '_ {
|
||||||
self.crates.iter().enumerate().map(|(idx, krate)| (CrateId(idx as u32), krate))
|
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 {
|
pub fn path(&self) -> &AbsPath {
|
||||||
&self.project_root
|
&self.project_root
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user