@@ -43,6 +43,8 @@ pub struct TreeOptions {
43
43
pub format : String ,
44
44
/// Includes features in the tree as separate nodes.
45
45
pub graph_features : bool ,
46
+ /// Maximum display depth of the dependency tree.
47
+ pub max_display_depth : u32 ,
46
48
/// Exculdes proc-macro dependencies.
47
49
pub no_proc_macro : bool ,
48
50
}
@@ -240,6 +242,7 @@ fn print(
240
242
symbols,
241
243
opts. prefix ,
242
244
opts. no_dedupe ,
245
+ opts. max_display_depth ,
243
246
opts. no_proc_macro ,
244
247
& mut visited_deps,
245
248
& mut levels_continue,
@@ -259,6 +262,7 @@ fn print_node<'a>(
259
262
symbols : & Symbols ,
260
263
prefix : Prefix ,
261
264
no_dedupe : bool ,
265
+ max_display_depth : u32 ,
262
266
no_proc_macro : bool ,
263
267
visited_deps : & mut HashSet < usize > ,
264
268
levels_continue : & mut Vec < bool > ,
@@ -317,6 +321,7 @@ fn print_node<'a>(
317
321
symbols,
318
322
prefix,
319
323
no_dedupe,
324
+ max_display_depth,
320
325
no_proc_macro,
321
326
visited_deps,
322
327
levels_continue,
@@ -336,6 +341,7 @@ fn print_dependencies<'a>(
336
341
symbols : & Symbols ,
337
342
prefix : Prefix ,
338
343
no_dedupe : bool ,
344
+ max_display_depth : u32 ,
339
345
no_proc_macro : bool ,
340
346
visited_deps : & mut HashSet < usize > ,
341
347
levels_continue : & mut Vec < bool > ,
@@ -383,20 +389,23 @@ fn print_dependencies<'a>(
383
389
. peekable ( ) ;
384
390
385
391
while let Some ( dependency) = it. next ( ) {
386
- levels_continue. push ( it. peek ( ) . is_some ( ) ) ;
387
- print_node (
388
- config,
389
- graph,
390
- * dependency,
391
- format,
392
- symbols,
393
- prefix,
394
- no_dedupe,
395
- no_proc_macro,
396
- visited_deps,
397
- levels_continue,
398
- print_stack,
399
- ) ;
400
- levels_continue. pop ( ) ;
392
+ if levels_continue. len ( ) + 1 <= max_display_depth as usize {
393
+ levels_continue. push ( it. peek ( ) . is_some ( ) ) ;
394
+ print_node (
395
+ config,
396
+ graph,
397
+ * dependency,
398
+ format,
399
+ symbols,
400
+ prefix,
401
+ no_dedupe,
402
+ max_display_depth,
403
+ no_proc_macro,
404
+ visited_deps,
405
+ levels_continue,
406
+ print_stack,
407
+ ) ;
408
+ levels_continue. pop ( ) ;
409
+ }
401
410
}
402
411
}
0 commit comments