File tree Expand file tree Collapse file tree 1 file changed +8
-4
lines changed Expand file tree Collapse file tree 1 file changed +8
-4
lines changed Original file line number Diff line number Diff line change @@ -294,7 +294,7 @@ pub(crate) fn does_nested_pattern(pat: &ast::Pat) -> bool {
294
294
false
295
295
}
296
296
297
- fn calc_depth ( pat : & ast:: Pat , mut depth : usize ) -> usize {
297
+ fn calc_depth ( pat : & ast:: Pat , depth : usize ) -> usize {
298
298
match pat {
299
299
ast:: Pat :: IdentPat ( _)
300
300
| ast:: Pat :: BoxPat ( _)
@@ -312,12 +312,16 @@ fn calc_depth(pat: &ast::Pat, mut depth: usize) -> usize {
312
312
| ast:: Pat :: TuplePat ( _)
313
313
| ast:: Pat :: ConstBlockPat ( _) => 1 ,
314
314
315
- // TODO implement
315
+ // TODO: Other patterns may also be nested. Currently it simply supports only `TupleStructPat`
316
316
ast:: Pat :: TupleStructPat ( pat) => {
317
+ let mut max_depth = depth;
317
318
for p in pat. fields ( ) {
318
- depth += calc_depth ( & p, depth + 1 ) ;
319
+ let d = calc_depth ( & p, depth + 1 ) ;
320
+ if d > max_depth {
321
+ max_depth = d
322
+ }
319
323
}
320
- depth
324
+ max_depth
321
325
}
322
326
}
323
327
}
You can’t perform that action at this time.
0 commit comments