@@ -156,25 +156,30 @@ impl BuildStep {
156
156
child. find_by_type ( r#type, result) ;
157
157
}
158
158
}
159
- }
160
-
161
- /// Writes build steps into a nice indented table.
162
- pub fn format_build_steps ( root : & BuildStep ) -> String {
163
- use std:: fmt:: Write ;
164
159
165
- let mut substeps: Vec < ( u32 , & BuildStep ) > = Vec :: new ( ) ;
160
+ /// Returns a Vec with all substeps, ordered by their hierarchical order.
161
+ /// The first element of the tuple is the depth of a given step.
162
+ fn linearize_steps ( & self ) -> Vec < ( u32 , & BuildStep ) > {
163
+ let mut substeps: Vec < ( u32 , & BuildStep ) > = Vec :: new ( ) ;
166
164
167
- fn visit < ' a > ( step : & ' a BuildStep , level : u32 , substeps : & mut Vec < ( u32 , & ' a BuildStep ) > ) {
168
- substeps. push ( ( level, step) ) ;
169
- for child in & step. children {
170
- visit ( child, level + 1 , substeps) ;
165
+ fn visit < ' a > ( step : & ' a BuildStep , level : u32 , substeps : & mut Vec < ( u32 , & ' a BuildStep ) > ) {
166
+ substeps. push ( ( level, step) ) ;
167
+ for child in & step. children {
168
+ visit ( child, level + 1 , substeps) ;
169
+ }
171
170
}
171
+
172
+ visit ( self , 0 , & mut substeps) ;
173
+ substeps
172
174
}
175
+ }
173
176
174
- visit ( root, 0 , & mut substeps) ;
177
+ /// Writes build steps into a nice indented table.
178
+ pub fn format_build_steps ( root : & BuildStep ) -> String {
179
+ use std:: fmt:: Write ;
175
180
176
181
let mut output = String :: new ( ) ;
177
- for ( level, step) in substeps {
182
+ for ( level, step) in root . linearize_steps ( ) {
178
183
let label = format ! (
179
184
"{}{}" ,
180
185
"." . repeat( level as usize ) ,
0 commit comments