@@ -247,7 +247,7 @@ fn eq_label_lt(lt1: &Option<ast::Lifetime>, lt2: &Option<ast::Lifetime>) -> bool
247
247
248
248
struct TreeWithDepthIterator {
249
249
preorder : Preorder < RustLanguage > ,
250
- depth : i32 ,
250
+ depth : u32 ,
251
251
}
252
252
253
253
impl TreeWithDepthIterator {
@@ -258,33 +258,31 @@ impl TreeWithDepthIterator {
258
258
}
259
259
260
260
impl < ' a > Iterator for TreeWithDepthIterator {
261
- type Item = ( ast:: Expr , i32 ) ;
261
+ type Item = ( ast:: Expr , u32 ) ;
262
262
263
263
fn next ( & mut self ) -> Option < Self :: Item > {
264
- while let Some ( ( event, expr ) ) = self . preorder . find_map ( |ev| match ev {
265
- WalkEvent :: Enter ( it) => Some ( WalkEvent :: Enter ( ( ) ) ) . zip ( ast:: Expr :: cast ( it) ) ,
266
- WalkEvent :: Leave ( it) => Some ( WalkEvent :: Leave ( ( ) ) ) . zip ( ast:: Expr :: cast ( it) ) ,
264
+ while let Some ( event) = self . preorder . find_map ( |ev| match ev {
265
+ WalkEvent :: Enter ( it) => ast:: Expr :: cast ( it) . map ( WalkEvent :: Enter ) ,
266
+ WalkEvent :: Leave ( it) => ast:: Expr :: cast ( it) . map ( WalkEvent :: Leave ) ,
267
267
} ) {
268
- match ( event, expr) {
269
- (
270
- WalkEvent :: Enter ( _) ,
268
+ match event {
269
+ WalkEvent :: Enter (
271
270
ast:: Expr :: LoopExpr ( _) | ast:: Expr :: WhileExpr ( _) | ast:: Expr :: ForExpr ( _) ,
272
271
) => {
273
272
self . depth += 1 ;
274
273
}
275
- (
276
- WalkEvent :: Leave ( _) ,
274
+ WalkEvent :: Leave (
277
275
ast:: Expr :: LoopExpr ( _) | ast:: Expr :: WhileExpr ( _) | ast:: Expr :: ForExpr ( _) ,
278
276
) => {
279
277
self . depth -= 1 ;
280
278
}
281
- ( WalkEvent :: Enter ( _ ) , ast:: Expr :: BlockExpr ( e) ) if e. label ( ) . is_some ( ) => {
279
+ WalkEvent :: Enter ( ast:: Expr :: BlockExpr ( e) ) if e. label ( ) . is_some ( ) => {
282
280
self . depth += 1 ;
283
281
}
284
- ( WalkEvent :: Leave ( _ ) , ast:: Expr :: BlockExpr ( e) ) if e. label ( ) . is_some ( ) => {
282
+ WalkEvent :: Leave ( ast:: Expr :: BlockExpr ( e) ) if e. label ( ) . is_some ( ) => {
285
283
self . depth -= 1 ;
286
284
}
287
- ( WalkEvent :: Enter ( _ ) , expr) => return Some ( ( expr, self . depth ) ) ,
285
+ WalkEvent :: Enter ( expr) => return Some ( ( expr, self . depth ) ) ,
288
286
_ => ( ) ,
289
287
}
290
288
}
0 commit comments