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 {
3434}
3535
3636impl 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 }
You can’t perform that action at this time.
0 commit comments