File tree Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -197,6 +197,23 @@ impl CrateGraph {
197197 self . arena . keys ( ) . copied ( )
198198 }
199199
200+ /// Returns an iterator over all transitive dependencies of the given crate.
201+ pub fn transitive_deps ( & self , of : CrateId ) -> impl Iterator < Item = CrateId > + ' _ {
202+ let mut worklist = vec ! [ of] ;
203+ let mut deps = FxHashSet :: default ( ) ;
204+
205+ while let Some ( krate) = worklist. pop ( ) {
206+ if !deps. insert ( krate) {
207+ continue ;
208+ }
209+
210+ worklist. extend ( self [ krate] . dependencies . iter ( ) . map ( |dep| dep. crate_id ) ) ;
211+ }
212+
213+ deps. remove ( & of) ;
214+ deps. into_iter ( )
215+ }
216+
200217 // FIXME: this only finds one crate with the given root; we could have multiple
201218 pub fn crate_id_for_crate_root ( & self , file_id : FileId ) -> Option < CrateId > {
202219 let ( & crate_id, _) =
You can’t perform that action at this time.
0 commit comments