File tree Expand file tree Collapse file tree 1 file changed +10
-0
lines changed Expand file tree Collapse file tree 1 file changed +10
-0
lines changed Original file line number Diff line number Diff line change @@ -34,6 +34,13 @@ pub struct Crate {
34
34
}
35
35
36
36
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.
37
44
pub fn new ( base : & AbsPath , data : ProjectJsonData ) -> ProjectJson {
38
45
ProjectJson {
39
46
sysroot_src : data. sysroot_src . map ( |it| base. join ( it) ) ,
@@ -85,12 +92,15 @@ impl ProjectJson {
85
92
. collect :: < Vec < _ > > ( ) ,
86
93
}
87
94
}
95
+ /// Returns the number of crates in the project.
88
96
pub fn n_crates ( & self ) -> usize {
89
97
self . crates . len ( )
90
98
}
99
+ /// Returns an iterator over the crates in the project.
91
100
pub fn crates ( & self ) -> impl Iterator < Item = ( CrateId , & Crate ) > + ' _ {
92
101
self . crates . iter ( ) . enumerate ( ) . map ( |( idx, krate) | ( CrateId ( idx as u32 ) , krate) )
93
102
}
103
+ /// Returns the path to the project's root folder.
94
104
pub fn path ( & self ) -> & AbsPath {
95
105
& self . project_root
96
106
}
You can’t perform that action at this time.
0 commit comments